rubocop-rspec 1.35.0 → 1.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/config/default.yml +11 -0
  4. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +16 -0
  5. data/lib/rubocop/cop/rspec/context_method.rb +53 -0
  6. data/lib/rubocop/cop/rspec/describe_class.rb +7 -10
  7. data/lib/rubocop/cop/rspec/described_class.rb +29 -1
  8. data/lib/rubocop/cop/rspec/empty_line_after_example.rb +87 -0
  9. data/lib/rubocop/cop/rspec/example_wording.rb +28 -12
  10. data/lib/rubocop/cop/rspec/expect_change.rb +8 -8
  11. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +2 -9
  12. data/lib/rubocop/cop/rspec/focus.rb +5 -10
  13. data/lib/rubocop/cop/rspec/instance_variable.rb +2 -1
  14. data/lib/rubocop/cop/rspec/multiple_expectations.rb +13 -21
  15. data/lib/rubocop/cop/rspec/pending.rb +19 -25
  16. data/lib/rubocop/cop/rspec_cops.rb +2 -0
  17. data/lib/rubocop/rspec/version.rb +1 -1
  18. metadata +7 -198
  19. data/Gemfile +0 -11
  20. data/Rakefile +0 -87
  21. data/rubocop-rspec.gemspec +0 -49
  22. data/spec/project/changelog_spec.rb +0 -76
  23. data/spec/project/default_config_spec.rb +0 -76
  24. data/spec/project/project_requires_spec.rb +0 -20
  25. data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +0 -51
  26. data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +0 -51
  27. data/spec/rubocop/cop/rspec/any_instance_spec.rb +0 -32
  28. data/spec/rubocop/cop/rspec/around_block_spec.rb +0 -121
  29. data/spec/rubocop/cop/rspec/be_eql_spec.rb +0 -81
  30. data/spec/rubocop/cop/rspec/be_spec.rb +0 -35
  31. data/spec/rubocop/cop/rspec/before_after_all_spec.rb +0 -52
  32. data/spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb +0 -65
  33. data/spec/rubocop/cop/rspec/capybara/feature_methods_spec.rb +0 -130
  34. data/spec/rubocop/cop/rspec/context_wording_spec.rb +0 -94
  35. data/spec/rubocop/cop/rspec/cop_spec.rb +0 -95
  36. data/spec/rubocop/cop/rspec/describe_class_spec.rb +0 -168
  37. data/spec/rubocop/cop/rspec/describe_method_spec.rb +0 -34
  38. data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +0 -44
  39. data/spec/rubocop/cop/rspec/described_class_spec.rb +0 -352
  40. data/spec/rubocop/cop/rspec/dialect_spec.rb +0 -78
  41. data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +0 -93
  42. data/spec/rubocop/cop/rspec/empty_line_after_example_group_spec.rb +0 -121
  43. data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +0 -239
  44. data/spec/rubocop/cop/rspec/empty_line_after_hook_spec.rb +0 -133
  45. data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +0 -94
  46. data/spec/rubocop/cop/rspec/example_length_spec.rb +0 -78
  47. data/spec/rubocop/cop/rspec/example_without_description_spec.rb +0 -92
  48. data/spec/rubocop/cop/rspec/example_wording_spec.rb +0 -173
  49. data/spec/rubocop/cop/rspec/expect_actual_spec.rb +0 -150
  50. data/spec/rubocop/cop/rspec/expect_change_spec.rb +0 -86
  51. data/spec/rubocop/cop/rspec/expect_in_hook_spec.rb +0 -79
  52. data/spec/rubocop/cop/rspec/expect_output_spec.rb +0 -62
  53. data/spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb +0 -208
  54. data/spec/rubocop/cop/rspec/factory_bot/create_list_spec.rb +0 -171
  55. data/spec/rubocop/cop/rspec/file_path_spec.rb +0 -200
  56. data/spec/rubocop/cop/rspec/focus_spec.rb +0 -139
  57. data/spec/rubocop/cop/rspec/hook_argument_spec.rb +0 -173
  58. data/spec/rubocop/cop/rspec/hooks_before_examples_spec.rb +0 -150
  59. data/spec/rubocop/cop/rspec/implicit_block_expectation_spec.rb +0 -135
  60. data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +0 -102
  61. data/spec/rubocop/cop/rspec/implicit_subject_spec.rb +0 -188
  62. data/spec/rubocop/cop/rspec/instance_spy_spec.rb +0 -61
  63. data/spec/rubocop/cop/rspec/instance_variable_spec.rb +0 -95
  64. data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +0 -39
  65. data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +0 -47
  66. data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +0 -82
  67. data/spec/rubocop/cop/rspec/leading_subject_spec.rb +0 -119
  68. data/spec/rubocop/cop/rspec/leaky_constant_declaration_spec.rb +0 -91
  69. data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +0 -137
  70. data/spec/rubocop/cop/rspec/let_setup_spec.rb +0 -66
  71. data/spec/rubocop/cop/rspec/message_chain_spec.rb +0 -23
  72. data/spec/rubocop/cop/rspec/message_expectation_spec.rb +0 -45
  73. data/spec/rubocop/cop/rspec/message_spies_spec.rb +0 -151
  74. data/spec/rubocop/cop/rspec/missing_example_group_argument_spec.rb +0 -57
  75. data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +0 -30
  76. data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +0 -261
  77. data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +0 -83
  78. data/spec/rubocop/cop/rspec/named_subject_spec.rb +0 -123
  79. data/spec/rubocop/cop/rspec/nested_groups_spec.rb +0 -81
  80. data/spec/rubocop/cop/rspec/not_to_not_spec.rb +0 -77
  81. data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +0 -91
  82. data/spec/rubocop/cop/rspec/pending_spec.rb +0 -186
  83. data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +0 -354
  84. data/spec/rubocop/cop/rspec/rails/http_status_spec.rb +0 -90
  85. data/spec/rubocop/cop/rspec/receive_counts_spec.rb +0 -138
  86. data/spec/rubocop/cop/rspec/receive_never_spec.rb +0 -57
  87. data/spec/rubocop/cop/rspec/repeated_description_spec.rb +0 -76
  88. data/spec/rubocop/cop/rspec/repeated_example_spec.rb +0 -74
  89. data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +0 -289
  90. data/spec/rubocop/cop/rspec/scattered_let_spec.rb +0 -28
  91. data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +0 -98
  92. data/spec/rubocop/cop/rspec/shared_context_spec.rb +0 -137
  93. data/spec/rubocop/cop/rspec/shared_examples_spec.rb +0 -75
  94. data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +0 -178
  95. data/spec/rubocop/cop/rspec/subject_stub_spec.rb +0 -293
  96. data/spec/rubocop/cop/rspec/unspecified_exception_spec.rb +0 -177
  97. data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +0 -86
  98. data/spec/rubocop/cop/rspec/void_expect_spec.rb +0 -49
  99. data/spec/rubocop/cop/rspec/yield_spec.rb +0 -81
  100. data/spec/rubocop/rspec/config_formatter_spec.rb +0 -52
  101. data/spec/rubocop/rspec/description_extractor_spec.rb +0 -63
  102. data/spec/rubocop/rspec/example_group_spec.rb +0 -44
  103. data/spec/rubocop/rspec/example_spec.rb +0 -62
  104. data/spec/rubocop/rspec/hook_spec.rb +0 -53
  105. data/spec/rubocop/rspec/language/selector_set_spec.rb +0 -53
  106. data/spec/rubocop/rspec/util/one_spec.rb +0 -23
  107. data/spec/rubocop/rspec/wording_spec.rb +0 -52
  108. data/spec/shared/autocorrect_behavior.rb +0 -9
  109. data/spec/shared/detects_style_behavior.rb +0 -9
  110. data/spec/shared/smoke_test_examples.rb +0 -27
  111. data/spec/smoke_tests/empty_spec.rb +0 -0
  112. data/spec/smoke_tests/factory_bot_spec.rb +0 -11
  113. data/spec/smoke_tests/no_tests_spec.rb +0 -4
  114. data/spec/smoke_tests/weird_rspec_spec.rb +0 -233
  115. data/spec/spec_helper.rb +0 -42
  116. data/spec/support/expect_offense.rb +0 -19
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::BeEql do
4
- subject(:cop) { described_class.new }
5
-
6
- it 'registers an offense for `eql` when argument is a boolean' do
7
- expect_offense(<<-RUBY)
8
- it { expect(foo).to eql(true) }
9
- ^^^ Prefer `be` over `eql`.
10
- it { expect(foo).to eql(false) }
11
- ^^^ Prefer `be` over `eql`.
12
- RUBY
13
-
14
- expect_correction(<<-RUBY)
15
- it { expect(foo).to be(true) }
16
- it { expect(foo).to be(false) }
17
- RUBY
18
- end
19
-
20
- it 'registers an offense for `eql` when argument is an integer' do
21
- expect_offense(<<-RUBY)
22
- it { expect(foo).to eql(0) }
23
- ^^^ Prefer `be` over `eql`.
24
- it { expect(foo).to eql(123) }
25
- ^^^ Prefer `be` over `eql`.
26
- RUBY
27
-
28
- expect_correction(<<-RUBY)
29
- it { expect(foo).to be(0) }
30
- it { expect(foo).to be(123) }
31
- RUBY
32
- end
33
-
34
- it 'registers an offense for `eql` when argument is a float' do
35
- expect_offense(<<-RUBY)
36
- it { expect(foo).to eql(1.0) }
37
- ^^^ Prefer `be` over `eql`.
38
- it { expect(foo).to eql(1.23) }
39
- ^^^ Prefer `be` over `eql`.
40
- RUBY
41
-
42
- expect_correction(<<-RUBY)
43
- it { expect(foo).to be(1.0) }
44
- it { expect(foo).to be(1.23) }
45
- RUBY
46
- end
47
-
48
- it 'registers an offense for `eql` when argument is a symbol' do
49
- expect_offense(<<-RUBY)
50
- it { expect(foo).to eql(:foo) }
51
- ^^^ Prefer `be` over `eql`.
52
- RUBY
53
-
54
- expect_correction(<<-RUBY)
55
- it { expect(foo).to be(:foo) }
56
- RUBY
57
- end
58
-
59
- it 'registers an offense for `eql` when argument is nil' do
60
- expect_offense(<<-RUBY)
61
- it { expect(foo).to eql(nil) }
62
- ^^^ Prefer `be` over `eql`.
63
- RUBY
64
-
65
- expect_correction(<<-RUBY)
66
- it { expect(foo).to be(nil) }
67
- RUBY
68
- end
69
-
70
- it 'does not register an offense for `eql` when argument is a string' do
71
- expect_no_offenses(<<-RUBY)
72
- it { expect(foo).to eql('foo') }
73
- RUBY
74
- end
75
-
76
- it 'does not register an offense for `eql` when expectation is negated' do
77
- expect_no_offenses(<<-RUBY)
78
- it { expect(foo).to_not eql(1) }
79
- RUBY
80
- end
81
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::Be do
4
- subject(:cop) { described_class.new }
5
-
6
- it 'registers an offense for `be` without an argument' do
7
- expect_offense(<<-RUBY)
8
- it { expect(foo).to be }
9
- ^^ Don't use `be` without an argument.
10
- RUBY
11
- end
12
-
13
- it 'registers an offense for not_to be' do
14
- expect_offense(<<-RUBY)
15
- it { expect(foo).not_to be }
16
- ^^ Don't use `be` without an argument.
17
- it { expect(foo).to_not be }
18
- ^^ Don't use `be` without an argument.
19
- RUBY
20
- end
21
-
22
- it 'allows `be` with an argument' do
23
- expect_no_offenses(<<-RUBY)
24
- it { expect(foo).to be(1) }
25
- it { expect(foo).not_to be(0) }
26
- RUBY
27
- end
28
-
29
- it 'allows specific `be_` matchers' do
30
- expect_no_offenses(<<-RUBY)
31
- it { expect(foo).to be_truthy }
32
- it { expect(foo).not_to be_falsy }
33
- RUBY
34
- end
35
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::BeforeAfterAll do
4
- subject(:cop) { described_class.new }
5
-
6
- def message(hook)
7
- "Beware of using `#{hook}` as it may cause state to leak between tests. "\
8
- 'If you are using `rspec-rails`, and `use_transactional_fixtures` is '\
9
- "enabled, then records created in `#{hook}` are not automatically rolled "\
10
- 'back.'
11
- end
12
-
13
- context 'when using before all' do
14
- it 'registers an offense' do
15
- expect_offense(<<-RUBY)
16
- before(:all) { do_something }
17
- ^^^^^^^^^^^^ #{message('before(:all)')}
18
- before(:context) { do_something }
19
- ^^^^^^^^^^^^^^^^ #{message('before(:context)')}
20
- RUBY
21
- end
22
- end
23
-
24
- context 'when using after all' do
25
- it 'registers an offense' do
26
- expect_offense(<<-RUBY)
27
- after(:all) { do_something }
28
- ^^^^^^^^^^^ #{message('after(:all)')}
29
- after(:context) { do_something }
30
- ^^^^^^^^^^^^^^^ #{message('after(:context)')}
31
- RUBY
32
- end
33
- end
34
-
35
- context 'when using before each' do
36
- it 'does not register an offense' do
37
- expect_no_offenses(<<-RUBY)
38
- before(:each) { do_something }
39
- before(:example) { do_something }
40
- RUBY
41
- end
42
- end
43
-
44
- context 'when using after each' do
45
- it 'does not register an offense' do
46
- expect_no_offenses(<<-RUBY)
47
- after(:each) { do_something }
48
- after(:example) { do_something }
49
- RUBY
50
- end
51
- end
52
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::Capybara::CurrentPathExpectation do
4
- subject(:cop) { described_class.new }
5
-
6
- it 'flags violations for `expect(current_path)`' do
7
- expect_offense(<<-RUBY)
8
- expect(current_path).to eq("/callback")
9
- ^^^^^^ Do not set an RSpec expectation on `current_path` in Capybara feature specs - instead, use the `have_current_path` matcher on `page`
10
- RUBY
11
- end
12
-
13
- it 'flags violations for `expect(page.current_path)`' do
14
- expect_offense(<<-RUBY)
15
- expect(page.current_path).to eq("/callback")
16
- ^^^^^^ Do not set an RSpec expectation on `current_path` in Capybara feature specs - instead, use the `have_current_path` matcher on `page`
17
- RUBY
18
- end
19
-
20
- it "doesn't flag a violation for other expectations" do
21
- expect_no_offenses(<<-RUBY)
22
- expect(current_user).to eq(user)
23
- RUBY
24
- end
25
-
26
- it "doesn't flag a violation for other references to `current_path`" do
27
- expect_no_offenses(<<-RUBY)
28
- current_path = WalkingRoute.last.path
29
- RUBY
30
- end
31
-
32
- include_examples 'autocorrect',
33
- 'expect(current_path).to eq expected_path',
34
- 'expect(page).to have_current_path expected_path'
35
-
36
- include_examples 'autocorrect',
37
- 'expect(page.current_path).to eq(foo(bar).path)',
38
- 'expect(page).to have_current_path(foo(bar).path)'
39
-
40
- include_examples 'autocorrect',
41
- 'expect(current_path).not_to eq expected_path',
42
- 'expect(page).to have_no_current_path expected_path'
43
-
44
- include_examples 'autocorrect',
45
- 'expect(current_path).to_not eq expected_path',
46
- 'expect(page).to have_no_current_path expected_path'
47
-
48
- include_examples 'autocorrect',
49
- 'expect(page.current_path).to match(/regexp/i)',
50
- 'expect(page).to have_current_path(/regexp/i)'
51
-
52
- include_examples 'autocorrect',
53
- 'expect(page.current_path).to match("string/")',
54
- 'expect(page).to have_current_path(/string\//)'
55
-
56
- # Unsupported, no change.
57
- include_examples 'autocorrect',
58
- 'expect(page.current_path).to match(variable)',
59
- 'expect(page.current_path).to match(variable)'
60
-
61
- # Unsupported, no change.
62
- include_examples 'autocorrect',
63
- 'expect(page.current_path)',
64
- 'expect(page.current_path)'
65
- end
@@ -1,130 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::Capybara::FeatureMethods, :config do
4
- subject(:cop) { described_class.new(config) }
5
-
6
- let(:cop_config) { { 'EnabledMethods' => [] } }
7
-
8
- it 'flags violations for `background`' do
9
- expect_offense(<<-RUBY)
10
- describe 'some feature' do
11
- background do; end
12
- ^^^^^^^^^^ Use `before` instead of `background`.
13
- end
14
- RUBY
15
- end
16
-
17
- it 'flags violations for `scenario`' do
18
- expect_offense(<<-RUBY)
19
- RSpec.describe 'some feature' do
20
- scenario 'Foo' do; end
21
- ^^^^^^^^ Use `it` instead of `scenario`.
22
- end
23
- RUBY
24
- end
25
-
26
- it 'flags violations for `xscenario`' do
27
- expect_offense(<<-RUBY)
28
- describe 'Foo' do
29
- RSpec.xscenario 'Baz' do; end
30
- ^^^^^^^^^ Use `xit` instead of `xscenario`.
31
- end
32
- RUBY
33
- end
34
-
35
- it 'flags violations for `given`' do
36
- expect_offense(<<-RUBY)
37
- RSpec.describe 'Foo' do
38
- given(:foo) { :foo }
39
- ^^^^^ Use `let` instead of `given`.
40
- end
41
- RUBY
42
- end
43
-
44
- it 'flags violations for `given!`' do
45
- expect_offense(<<-RUBY)
46
- describe 'Foo' do
47
- given!(:foo) { :foo }
48
- ^^^^^^ Use `let!` instead of `given!`.
49
- end
50
- RUBY
51
- end
52
-
53
- it 'flags violations for `feature`' do
54
- expect_offense(<<-RUBY)
55
- RSpec.feature 'Foo' do; end
56
- ^^^^^^^ Use `describe` instead of `feature`.
57
- RUBY
58
- end
59
-
60
- it 'ignores variables inside examples' do
61
- expect_no_offenses(<<-RUBY)
62
- it 'is valid code' do
63
- given(feature)
64
- assign(background)
65
- run scenario
66
- end
67
- RUBY
68
- end
69
-
70
- it 'ignores feature calls outside spec' do
71
- expect_no_offenses(<<-RUBY)
72
- FactoryBot.define do
73
- factory :company do
74
- feature { "a company" }
75
- background { Faker::Lorem.sentence }
76
- end
77
- end
78
- RUBY
79
- end
80
-
81
- it 'allows includes before the spec' do
82
- expect_offense(<<-RUBY)
83
- require 'rails_helper'
84
-
85
- RSpec.feature 'Foo' do; end
86
- ^^^^^^^ Use `describe` instead of `feature`.
87
- RUBY
88
- end
89
-
90
- context 'with configured `EnabledMethods`' do
91
- let(:cop_config) { { 'EnabledMethods' => %w[feature] } }
92
-
93
- it 'ignores usage of the enabled method' do
94
- expect_no_offenses(<<-RUBY)
95
- RSpec.feature 'feature is enabled' do; end
96
- RUBY
97
- end
98
-
99
- it 'flags other methods' do
100
- expect_offense(<<-RUBY)
101
- RSpec.feature 'feature is enabled' do
102
- given(:foo) { :foo }
103
- ^^^^^ Use `let` instead of `given`.
104
- end
105
- RUBY
106
- end
107
- end
108
-
109
- shared_examples 'autocorrect_spec' do |original, corrected|
110
- original = <<-RUBY
111
- describe Foo do
112
- #{original}
113
- end
114
- RUBY
115
- corrected = <<-RUBY
116
- describe Foo do
117
- #{corrected}
118
- end
119
- RUBY
120
-
121
- include_examples 'autocorrect', original, corrected
122
- end
123
-
124
- include_examples 'autocorrect_spec', 'background { }', 'before { }'
125
- include_examples 'autocorrect_spec', 'scenario { }', 'it { }'
126
- include_examples 'autocorrect_spec', 'xscenario { }', 'xit { }'
127
- include_examples 'autocorrect_spec', 'given(:foo) { }', 'let(:foo) { }'
128
- include_examples 'autocorrect_spec', 'given!(:foo) { }', 'let!(:foo) { }'
129
- include_examples 'autocorrect_spec', 'RSpec.feature { }', 'RSpec.describe { }'
130
- end
@@ -1,94 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::ContextWording, :config do
4
- subject(:cop) { described_class.new(config) }
5
-
6
- let(:cop_config) { { 'Prefixes' => %w[when with] } }
7
-
8
- it 'skips describe blocks' do
9
- expect_no_offenses(<<-RUBY)
10
- describe 'the display name not present' do
11
- end
12
- RUBY
13
- end
14
-
15
- it 'finds context without `when` at the beginning' do
16
- expect_offense(<<-RUBY)
17
- context 'the display name not present' do
18
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Start context description with 'when', or 'with'.
19
- end
20
- RUBY
21
- end
22
-
23
- it 'finds shared_context without `when` at the beginning' do
24
- expect_offense(<<-RUBY)
25
- shared_context 'the display name not present' do
26
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Start context description with 'when', or 'with'.
27
- end
28
- RUBY
29
- end
30
-
31
- it "skips descriptions beginning with 'when'" do
32
- expect_no_offenses(<<-RUBY)
33
- context 'when the display name is not present' do
34
- end
35
- RUBY
36
- end
37
-
38
- it 'finds context without separate `when` at the beginning' do
39
- expect_offense(<<-RUBY)
40
- context 'whenever you do' do
41
- ^^^^^^^^^^^^^^^^^ Start context description with 'when', or 'with'.
42
- end
43
- RUBY
44
- end
45
-
46
- context 'with metadata hash' do
47
- it 'finds context without separate `when` at the beginning' do
48
- expect_offense(<<-RUBY)
49
- context 'whenever you do', legend: true do
50
- ^^^^^^^^^^^^^^^^^ Start context description with 'when', or 'with'.
51
- end
52
- RUBY
53
- end
54
- end
55
-
56
- context 'with symbol metadata' do
57
- it 'finds context without separate `when` at the beginning' do
58
- expect_offense(<<-RUBY)
59
- context 'whenever you do', :legend do
60
- ^^^^^^^^^^^^^^^^^ Start context description with 'when', or 'with'.
61
- end
62
- RUBY
63
- end
64
- end
65
-
66
- context 'with mixed metadata' do
67
- it 'finds context without separate `when` at the beginning' do
68
- expect_offense(<<-RUBY)
69
- context 'whenever you do', :legend, myth: true do
70
- ^^^^^^^^^^^^^^^^^ Start context description with 'when', or 'with'.
71
- end
72
- RUBY
73
- end
74
- end
75
-
76
- context 'when configured' do
77
- let(:cop_config) { { 'Prefixes' => %w[if] } }
78
-
79
- it 'finds context without whitelisted prefixes at the beginning' do
80
- expect_offense(<<-RUBY)
81
- context 'when display name is present' do
82
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Start context description with 'if'.
83
- end
84
- RUBY
85
- end
86
-
87
- it 'skips descriptions with whitelisted prefixes at the beginning' do
88
- expect_no_offenses(<<-RUBY)
89
- context 'if display name is present' do
90
- end
91
- RUBY
92
- end
93
- end
94
- end