Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/gitlab/json_spec.rb')
-rw-r--r--spec/rubocop/cop/gitlab/json_spec.rb33
1 files changed, 8 insertions, 25 deletions
diff --git a/spec/rubocop/cop/gitlab/json_spec.rb b/spec/rubocop/cop/gitlab/json_spec.rb
index fc25f69a244..29c3b96cc1a 100644
--- a/spec/rubocop/cop/gitlab/json_spec.rb
+++ b/spec/rubocop/cop/gitlab/json_spec.rb
@@ -2,38 +2,21 @@
require 'fast_spec_helper'
require 'rubocop'
-require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/gitlab/json'
RSpec.describe RuboCop::Cop::Gitlab::Json do
- include CopHelper
-
subject(:cop) { described_class.new }
- shared_examples('registering call offense') do |options|
- let(:offending_lines) { options[:offending_lines] }
-
- it 'registers an offense when the class calls JSON' do
- inspect_source(source)
-
- aggregate_failures do
- expect(cop.offenses.size).to eq(offending_lines.size)
- expect(cop.offenses.map(&:line)).to eq(offending_lines)
- end
- end
- end
-
context 'when JSON is called' do
- it_behaves_like 'registering call offense', offending_lines: [3] do
- let(:source) do
- <<~RUBY
- class Foo
- def bar
- JSON.parse('{ "foo": "bar" }')
- end
+ it 'registers an offense' do
+ expect_offense(<<~RUBY)
+ class Foo
+ def bar
+ JSON.parse('{ "foo": "bar" }')
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid calling `JSON` directly. [...]
end
- RUBY
- end
+ end
+ RUBY
end
end
end