-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
redundant_context_config_parameter_spec.rb
50 lines (43 loc) · 1.24 KB
/
redundant_context_config_parameter_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::InternalAffairs::RedundantContextConfigParameter, :config do
it 'registers an offense when using `:config` parameter' do
expect_offense(<<~RUBY)
context 'foo', :config do
^^^^^^^ Remove the redundant `:config` parameter.
end
RUBY
expect_correction(<<~RUBY)
context 'foo' do
end
RUBY
end
it 'registers an offense when using `:config` parameter with other parameters' do
expect_offense(<<~RUBY)
context 'foo', :ruby30, :rails70, :config do
^^^^^^^ Remove the redundant `:config` parameter.
end
RUBY
expect_correction(<<~RUBY)
context 'foo', :ruby30, :rails70 do
end
RUBY
end
it 'does not register an offense when not using `:config`' do
expect_no_offenses(<<~RUBY)
context 'foo' do
end
RUBY
end
it 'does not register an offense when using `:ruby30` only' do
expect_no_offenses(<<~RUBY)
context 'foo', :ruby30 do
end
RUBY
end
it 'does not register an offense when using `:config` in other than `context`' do
expect_no_offenses(<<~RUBY)
shared_context 'foo', :config do
end
RUBY
end
end