diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 09:07:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 09:07:11 +0300 |
commit | 75621c94b5dbe233edd72c3d8cc602fed25e84d2 (patch) | |
tree | a38d832241e66a2e296e276493bff0260bfc9712 /spec/rubocop/cop/graphql | |
parent | 9bf8cb8d34039f3cef9e1b2f812ce634f2bebe69 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/graphql')
-rw-r--r-- | spec/rubocop/cop/graphql/resource_not_available_error_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/rubocop/cop/graphql/resource_not_available_error_spec.rb b/spec/rubocop/cop/graphql/resource_not_available_error_spec.rb new file mode 100644 index 00000000000..6003b9f3954 --- /dev/null +++ b/spec/rubocop/cop/graphql/resource_not_available_error_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'rubocop_spec_helper' + +require_relative '../../../../rubocop/cop/graphql/resource_not_available_error' + +RSpec.describe RuboCop::Cop::Graphql::ResourceNotAvailableError, feature_category: :shared do + shared_examples 'flagging and auto-correction' do |exception| + it "flags and auto-corrects `raise #{exception}`" do + expect_offense(<<~'RUBY', exception: exception) + raise %{exception} + ^^^^^^^{exception} Prefer using `raise_resource_not_available_error!` instead. + + raise %{exception}, 'message ' \ + ^^^^^^^{exception}^^^^^^^^^^^^^^ Prefer using `raise_resource_not_available_error!` instead. + 'with new lines' + RUBY + + expect_correction(<<~'RUBY') + raise_resource_not_available_error! + + raise_resource_not_available_error! 'message ' \ + 'with new lines' + RUBY + end + end + + it_behaves_like 'flagging and auto-correction', 'Gitlab::Graphql::Errors::ResourceNotAvailable' + it_behaves_like 'flagging and auto-correction', '::Gitlab::Graphql::Errors::ResourceNotAvailable' + + it 'does not flag unrelated exceptions' do + expect_no_offenses(<<~RUBY) + raise Gitlab::Graphql::Errors::ResourceVeryAvailable + raise ::Gitlab::Graphql::Errors::ResourceVeryAvailable + RUBY + end +end |