debian-mirror-gitlab/spec/rubocop/cop/gitlab/json_spec.rb

22 lines
512 B
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
2020-07-28 23:09:34 +05:30
require 'fast_spec_helper'
2020-05-24 23:13:21 +05:30
require_relative '../../../../rubocop/cop/gitlab/json'
2021-03-08 18:12:59 +05:30
RSpec.describe RuboCop::Cop::Gitlab::Json do
2020-05-24 23:13:21 +05:30
subject(:cop) { described_class.new }
context 'when JSON is called' do
2021-03-11 19:13:27 +05:30
it 'registers an offense' do
expect_offense(<<~RUBY)
class Foo
def bar
JSON.parse('{ "foo": "bar" }')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid calling `JSON` directly. [...]
2020-05-24 23:13:21 +05:30
end
2021-03-11 19:13:27 +05:30
end
RUBY
2020-05-24 23:13:21 +05:30
end
end
end