rubocop-rspec 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/config/default.yml +15 -1
  4. data/lib/rubocop-rspec.rb +2 -0
  5. data/lib/rubocop/cop/rspec/any_instance.rb +7 -10
  6. data/lib/rubocop/cop/rspec/around_block.rb +19 -30
  7. data/lib/rubocop/cop/rspec/be_eql.rb +3 -7
  8. data/lib/rubocop/cop/rspec/before_after_all.rb +10 -16
  9. data/lib/rubocop/cop/rspec/cop.rb +5 -1
  10. data/lib/rubocop/cop/rspec/describe_class.rb +8 -8
  11. data/lib/rubocop/cop/rspec/describe_method.rb +6 -5
  12. data/lib/rubocop/cop/rspec/described_class.rb +2 -2
  13. data/lib/rubocop/cop/rspec/example_length.rb +5 -8
  14. data/lib/rubocop/cop/rspec/example_wording.rb +57 -23
  15. data/lib/rubocop/cop/rspec/expect_actual.rb +3 -9
  16. data/lib/rubocop/cop/rspec/expect_output.rb +2 -2
  17. data/lib/rubocop/cop/rspec/file_path.rb +30 -29
  18. data/lib/rubocop/cop/rspec/hook_argument.rb +1 -1
  19. data/lib/rubocop/cop/rspec/instance_spy.rb +12 -12
  20. data/lib/rubocop/cop/rspec/instance_variable.rb +2 -2
  21. data/lib/rubocop/cop/rspec/it_behaves_like.rb +47 -0
  22. data/lib/rubocop/cop/rspec/leading_subject.rb +1 -1
  23. data/lib/rubocop/cop/rspec/message_chain.rb +7 -4
  24. data/lib/rubocop/cop/rspec/message_spies.rb +6 -5
  25. data/lib/rubocop/cop/rspec/multiple_describes.rb +1 -1
  26. data/lib/rubocop/cop/rspec/multiple_expectations.rb +38 -6
  27. data/lib/rubocop/cop/rspec/named_subject.rb +2 -2
  28. data/lib/rubocop/cop/rspec/nested_groups.rb +10 -6
  29. data/lib/rubocop/cop/rspec/not_to_not.rb +12 -23
  30. data/lib/rubocop/cop/rspec/shared_context.rb +107 -0
  31. data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +16 -23
  32. data/lib/rubocop/cop/rspec/subject_stub.rb +4 -4
  33. data/lib/rubocop/cop/rspec/verified_doubles.rb +4 -3
  34. data/lib/rubocop/rspec/example_group.rb +1 -1
  35. data/lib/rubocop/rspec/language.rb +25 -7
  36. data/lib/rubocop/rspec/version.rb +1 -1
  37. data/spec/expect_violation/expectation_spec.rb +16 -16
  38. data/spec/project/changelog_spec.rb +1 -1
  39. data/spec/project/default_config_spec.rb +1 -1
  40. data/spec/project/project_requires_spec.rb +1 -1
  41. data/spec/rubocop/cop/rspec/any_instance_spec.rb +4 -4
  42. data/spec/rubocop/cop/rspec/around_block_spec.rb +115 -26
  43. data/spec/rubocop/cop/rspec/be_eql_spec.rb +9 -9
  44. data/spec/rubocop/cop/rspec/before_after_all_spec.rb +38 -80
  45. data/spec/rubocop/cop/rspec/describe_class_spec.rb +1 -1
  46. data/spec/rubocop/cop/rspec/describe_method_spec.rb +2 -2
  47. data/spec/rubocop/cop/rspec/described_class_spec.rb +13 -13
  48. data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +1 -1
  49. data/spec/rubocop/cop/rspec/example_length_spec.rb +3 -32
  50. data/spec/rubocop/cop/rspec/example_wording_spec.rb +21 -2
  51. data/spec/rubocop/cop/rspec/expect_actual_spec.rb +33 -18
  52. data/spec/rubocop/cop/rspec/expect_output_spec.rb +3 -3
  53. data/spec/rubocop/cop/rspec/file_path_spec.rb +119 -170
  54. data/spec/rubocop/cop/rspec/focus_spec.rb +1 -1
  55. data/spec/rubocop/cop/rspec/hook_argument_spec.rb +1 -3
  56. data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +1 -1
  57. data/spec/rubocop/cop/rspec/instance_spy_spec.rb +11 -11
  58. data/spec/rubocop/cop/rspec/instance_variable_spec.rb +4 -4
  59. data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +51 -0
  60. data/spec/rubocop/cop/rspec/leading_subject_spec.rb +1 -1
  61. data/spec/rubocop/cop/rspec/let_setup_spec.rb +1 -1
  62. data/spec/rubocop/cop/rspec/message_chain_spec.rb +3 -3
  63. data/spec/rubocop/cop/rspec/message_expectation_spec.rb +5 -23
  64. data/spec/rubocop/cop/rspec/message_spies_spec.rb +9 -23
  65. data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +1 -1
  66. data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +66 -3
  67. data/spec/rubocop/cop/rspec/nested_groups_spec.rb +4 -4
  68. data/spec/rubocop/cop/rspec/not_to_not_spec.rb +3 -3
  69. data/spec/rubocop/cop/rspec/repeated_description_spec.rb +1 -1
  70. data/spec/rubocop/cop/rspec/repeated_example_spec.rb +1 -1
  71. data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +1 -1
  72. data/spec/rubocop/cop/rspec/shared_context_spec.rb +142 -0
  73. data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +5 -5
  74. data/spec/rubocop/cop/rspec/subject_stub_spec.rb +1 -1
  75. data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +2 -2
  76. data/spec/rubocop/rspec/config_formatter_spec.rb +12 -12
  77. data/spec/rubocop/rspec/description_extractor_spec.rb +23 -23
  78. data/spec/rubocop/rspec/example_group_spec.rb +11 -11
  79. data/spec/rubocop/rspec/example_spec.rb +1 -1
  80. data/spec/rubocop/rspec/language/selector_set_spec.rb +1 -1
  81. data/spec/rubocop/rspec/util/one_spec.rb +1 -1
  82. data/spec/rubocop/rspec/wording_spec.rb +1 -1
  83. data/spec/shared/detects_style_behavior.rb +3 -4
  84. data/spec/spec_helper.rb +10 -0
  85. metadata +8 -2
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::Focus do
1
+ RSpec.describe RuboCop::Cop::RSpec::Focus do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  # rubocop:disable RSpec/ExampleLength
@@ -1,14 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
- describe RuboCop::Cop::RSpec::HookArgument, :config do
3
+ RSpec.describe RuboCop::Cop::RSpec::HookArgument, :config do
4
4
  subject(:cop) { described_class.new(config) }
5
5
 
6
6
  let(:cop_config) do
7
7
  { 'EnforcedStyle' => enforced_style }
8
8
  end
9
9
 
10
- let(:enforced_style) { :implicit }
11
-
12
10
  shared_examples 'ignored hooks' do
13
11
  it 'ignores :context and :suite' do
14
12
  expect_no_violations(<<-RUBY)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe RuboCop::Cop::RSpec::ImplicitExpect, :config do
3
+ RSpec.describe RuboCop::Cop::RSpec::ImplicitExpect, :config do
4
4
  subject(:cop) { described_class.new(config) }
5
5
 
6
6
  context 'when EnforcedStyle is is_expected' do
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::InstanceSpy do
1
+ RSpec.describe RuboCop::Cop::RSpec::InstanceSpy do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  context 'when used with `have_received`' do
@@ -6,7 +6,7 @@ describe RuboCop::Cop::RSpec::InstanceSpy do
6
6
  expect_violation(<<-RUBY)
7
7
  it do
8
8
  foo = instance_double(Foo).as_null_object
9
- ^^^^^^^^^^^^^^^^^^^^ Use `instance_spy` when you check your double with `have_received`
9
+ ^^^^^^^^^^^^^^^^^^^^ Use `instance_spy` when you check your double with `have_received`.
10
10
  expect(foo).to have_received(:bar)
11
11
  end
12
12
  RUBY
@@ -16,7 +16,7 @@ describe RuboCop::Cop::RSpec::InstanceSpy do
16
16
  expect_violation(<<-RUBY)
17
17
  it do
18
18
  foo = instance_double(Foo, :name).as_null_object
19
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `instance_spy` when you check your double with `have_received`
19
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `instance_spy` when you check your double with `have_received`.
20
20
  expect(foo).to have_received(:bar)
21
21
  end
22
22
  RUBY
@@ -44,16 +44,16 @@ describe RuboCop::Cop::RSpec::InstanceSpy do
44
44
  end
45
45
 
46
46
  original = <<-RUBY
47
- it do
48
- foo = instance_double(Foo, :name).as_null_object
49
- expect(foo).to have_received(:bar)
50
- end
47
+ it do
48
+ foo = instance_double(Foo, :name).as_null_object
49
+ expect(foo).to have_received(:bar)
50
+ end
51
51
  RUBY
52
52
  corrected = <<-RUBY
53
- it do
54
- foo = instance_spy(Foo, :name)
55
- expect(foo).to have_received(:bar)
56
- end
53
+ it do
54
+ foo = instance_spy(Foo, :name)
55
+ expect(foo).to have_received(:bar)
56
+ end
57
57
  RUBY
58
58
 
59
59
  include_examples 'autocorrect', original, corrected
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::InstanceVariable do
1
+ RSpec.describe RuboCop::Cop::RSpec::InstanceVariable do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'finds an instance variable inside a describe' do
@@ -6,7 +6,7 @@ describe RuboCop::Cop::RSpec::InstanceVariable do
6
6
  describe MyClass do
7
7
  before { @foo = [] }
8
8
  it { expect(@foo).to be_empty }
9
- ^^^^ Use `let` instead of an instance variable
9
+ ^^^^ Use `let` instead of an instance variable.
10
10
  end
11
11
  RUBY
12
12
  end
@@ -24,7 +24,7 @@ describe RuboCop::Cop::RSpec::InstanceVariable do
24
24
  expect_violation(<<-RUBY)
25
25
  shared_examples 'shared example' do
26
26
  it { expect(@foo).to be_empty }
27
- ^^^^ Use `let` instead of an instance variable
27
+ ^^^^ Use `let` instead of an instance variable.
28
28
  end
29
29
  RUBY
30
30
  end
@@ -59,7 +59,7 @@ describe RuboCop::Cop::RSpec::InstanceVariable do
59
59
  describe MyClass do
60
60
  before { @foo = [] }
61
61
  it { expect(@foo).to be_empty }
62
- ^^^^ Use `let` instead of an instance variable
62
+ ^^^^ Use `let` instead of an instance variable.
63
63
  end
64
64
  RUBY
65
65
  end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe RuboCop::Cop::RSpec::ItBehavesLike, :config do
4
+ subject(:cop) { described_class.new(config) }
5
+
6
+ let(:cop_config) do
7
+ { 'EnforcedStyle' => enforced_style }
8
+ end
9
+
10
+ context 'when the enforced style is `it_behaves_like`' do
11
+ let(:enforced_style) { :it_behaves_like }
12
+
13
+ it 'flags a violation for it_should_behave_like' do
14
+ expect_violation(<<-RUBY)
15
+ it_should_behave_like 'a foo'
16
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `it_behaves_like` over `it_should_behave_like` when including examples in a nested context.
17
+ RUBY
18
+ end
19
+
20
+ it 'does not flag a violation for it_behaves_like' do
21
+ expect_no_violations("it_behaves_like 'a foo'")
22
+ end
23
+
24
+ include_examples(
25
+ 'autocorrect',
26
+ "foo(); it_should_behave_like 'a foo'",
27
+ "foo(); it_behaves_like 'a foo'"
28
+ )
29
+ end
30
+
31
+ context 'when the enforced style is `it_should_behave_like`' do
32
+ let(:enforced_style) { :it_should_behave_like }
33
+
34
+ it 'flags a violation for it_behaves_like' do
35
+ expect_violation(<<-RUBY)
36
+ it_behaves_like 'a foo'
37
+ ^^^^^^^^^^^^^^^^^^^^^^^ Prefer `it_should_behave_like` over `it_behaves_like` when including examples in a nested context.
38
+ RUBY
39
+ end
40
+
41
+ it 'does not flag a violation for it_behaves_like' do
42
+ expect_no_violations("it_should_behave_like 'a foo'")
43
+ end
44
+
45
+ include_examples(
46
+ 'autocorrect',
47
+ "foo(); it_behaves_like 'a foo'",
48
+ "foo(); it_should_behave_like 'a foo'"
49
+ )
50
+ end
51
+ end
@@ -9,7 +9,7 @@ RSpec.describe RuboCop::Cop::RSpec::LeadingSubject do
9
9
  let(:params) { foo }
10
10
 
11
11
  subject { described_class.new }
12
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Declare `subject` above any other `let` declarations
12
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Declare `subject` above any other `let` declarations.
13
13
  end
14
14
  RUBY
15
15
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe RuboCop::Cop::RSpec::LetSetup do
3
+ RSpec.describe RuboCop::Cop::RSpec::LetSetup do
4
4
  subject(:cop) { described_class.new }
5
5
 
6
6
  it 'complains when let! is used and not referenced' do
@@ -1,11 +1,11 @@
1
- describe RuboCop::Cop::RSpec::MessageChain do
1
+ RSpec.describe RuboCop::Cop::RSpec::MessageChain do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'finds `receive_message_chain`' do
5
5
  expect_violation(<<-RUBY)
6
6
  before do
7
7
  allow(foo).to receive_message_chain(:one, :two) { :three }
8
- ^^^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `receive_message_chain`
8
+ ^^^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `receive_message_chain`.
9
9
  end
10
10
  RUBY
11
11
  end
@@ -14,7 +14,7 @@ describe RuboCop::Cop::RSpec::MessageChain do
14
14
  expect_violation(<<-RUBY)
15
15
  before do
16
16
  foo.stub_chain(:one, :two).and_return(:three)
17
- ^^^^^^^^^^ Avoid stubbing using `stub_chain`
17
+ ^^^^^^^^^^ Avoid stubbing using `stub_chain`.
18
18
  end
19
19
  RUBY
20
20
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe RuboCop::Cop::RSpec::MessageExpectation, :config do
3
+ RSpec.describe RuboCop::Cop::RSpec::MessageExpectation, :config do
4
4
  subject(:cop) { described_class.new(config) }
5
5
 
6
6
  context 'when EnforcedStyle is allow' do
@@ -19,17 +19,8 @@ describe RuboCop::Cop::RSpec::MessageExpectation, :config do
19
19
  expect_no_violations('allow(foo).to receive(:bar)')
20
20
  end
21
21
 
22
- it 'generates a todo based on the usage of the correct style' do
23
- inspect_source(cop, 'allow(foo).to receive(:bar)', 'foo_spec.rb')
24
-
25
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'allow')
26
- end
27
-
28
- it 'generates a todo based on the usage of the alternate style' do
29
- inspect_source(cop, 'expect(foo).to receive(:bar)', 'foo_spec.rb')
30
-
31
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'expect')
32
- end
22
+ include_examples 'detects style', 'allow(foo).to receive(:bar)', 'allow'
23
+ include_examples 'detects style', 'expect(foo).to receive(:bar)', 'expect'
33
24
  end
34
25
 
35
26
  context 'when EnforcedStyle is expect' do
@@ -48,16 +39,7 @@ describe RuboCop::Cop::RSpec::MessageExpectation, :config do
48
39
  expect_no_violations('expect(foo).to receive(:bar)')
49
40
  end
50
41
 
51
- it 'generates a todo based on the usage of the correct style' do
52
- inspect_source(cop, 'expect(foo).to receive(:bar)', 'foo_spec.rb')
53
-
54
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'expect')
55
- end
56
-
57
- it 'generates a todo based on the usage of the alternate style' do
58
- inspect_source(cop, 'allow(foo).to receive(:bar)', 'foo_spec.rb')
59
-
60
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'allow')
61
- end
42
+ include_examples 'detects style', 'expect(foo).to receive(:bar)', 'expect'
43
+ include_examples 'detects style', 'allow(foo).to receive(:bar)', 'allow'
62
44
  end
63
45
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe RuboCop::Cop::RSpec::MessageSpies, :config do
3
+ RSpec.describe RuboCop::Cop::RSpec::MessageSpies, :config do
4
4
  subject(:cop) { described_class.new(config) }
5
5
 
6
6
  context 'when EnforcedStyle is have_received' do
@@ -69,18 +69,11 @@ describe RuboCop::Cop::RSpec::MessageSpies, :config do
69
69
  expect_no_violations('expect(foo).to have_received(:bar)')
70
70
  end
71
71
 
72
- it 'generates a todo based on the usage of the correct style' do
73
- inspect_source(cop, 'expect(foo).to have_received(:bar)', 'foo_spec.rb')
72
+ include_examples 'detects style', 'expect(foo).to receive(:bar)', 'receive'
74
73
 
75
- expect(cop.config_to_allow_offenses)
76
- .to eq('EnforcedStyle' => 'have_received')
77
- end
78
-
79
- it 'generates a todo based on the usage of the alternate style' do
80
- inspect_source(cop, 'expect(foo).to receive(:bar)', 'foo_spec.rb')
81
-
82
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'receive')
83
- end
74
+ include_examples 'detects style',
75
+ 'expect(foo).to have_received(:bar)',
76
+ 'have_received'
84
77
  end
85
78
 
86
79
  context 'when EnforcedStyle is receive' do
@@ -149,17 +142,10 @@ describe RuboCop::Cop::RSpec::MessageSpies, :config do
149
142
  expect_no_violations('expect(foo).to receive(:bar)')
150
143
  end
151
144
 
152
- it 'generates a todo based on the usage of the correct style' do
153
- inspect_source(cop, 'expect(foo).to receive(:bar)', 'foo_spec.rb')
145
+ include_examples 'detects style', 'expect(foo).to receive(:bar)', 'receive'
154
146
 
155
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'receive')
156
- end
157
-
158
- it 'generates a todo based on the usage of the alternate style' do
159
- inspect_source(cop, 'expect(foo).to have_received(:bar)', 'foo_spec.rb')
160
-
161
- expect(cop.config_to_allow_offenses)
162
- .to eq('EnforcedStyle' => 'have_received')
163
- end
147
+ include_examples 'detects style',
148
+ 'expect(foo).to have_received(:bar)',
149
+ 'have_received'
164
150
  end
165
151
  end
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::MultipleDescribes do
1
+ RSpec.describe RuboCop::Cop::RSpec::MultipleDescribes do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'finds multiple top level describes with class and method' do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe RuboCop::Cop::RSpec::MultipleExpectations, :config do
3
+ RSpec.describe RuboCop::Cop::RSpec::MultipleExpectations, :config do
4
4
  subject(:cop) { described_class.new(config) }
5
5
 
6
6
  context 'without configuration' do
@@ -10,7 +10,7 @@ describe RuboCop::Cop::RSpec::MultipleExpectations, :config do
10
10
  expect_violation(<<-RUBY)
11
11
  describe Foo do
12
12
  it 'uses expect twice' do
13
- ^^^^^^^^^^^^^^^^^^^^^^ Example has too many expectations [2/1]
13
+ ^^^^^^^^^^^^^^^^^^^^^^ Example has too many expectations [2/1].
14
14
  expect(foo).to eq(bar)
15
15
  expect(baz).to eq(bar)
16
16
  end
@@ -31,6 +31,69 @@ describe RuboCop::Cop::RSpec::MultipleExpectations, :config do
31
31
  end
32
32
  RUBY
33
33
  end
34
+
35
+ it 'counts aggregate_failures as one expectation' do
36
+ expect_no_violations(<<-RUBY)
37
+ describe Foo do
38
+ it 'aggregates failures' do
39
+ aggregate_failures do
40
+ expect(foo).to eq(bar)
41
+ expect(baz).to eq(bar)
42
+ end
43
+ end
44
+ end
45
+ RUBY
46
+ end
47
+
48
+ it 'counts every aggregate_failures as an expectation' do
49
+ expect_violation(<<-RUBY)
50
+ describe Foo do
51
+ it 'has multiple aggregate_failures calls' do
52
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Example has too many expectations [2/1].
53
+ aggregate_failures do
54
+ end
55
+ aggregate_failures do
56
+ end
57
+ end
58
+ end
59
+ RUBY
60
+ end
61
+ end
62
+
63
+ context 'with meta data' do
64
+ it 'ignores examples with `:aggregate_failures`' do
65
+ expect_no_violations(<<-RUBY)
66
+ describe Foo do
67
+ it 'uses expect twice', :aggregate_failures do
68
+ expect(foo).to eq(bar)
69
+ expect(baz).to eq(bar)
70
+ end
71
+ end
72
+ RUBY
73
+ end
74
+
75
+ it 'ignores examples with `aggregate_failures: true`' do
76
+ expect_no_violations(<<-RUBY)
77
+ describe Foo do
78
+ it 'uses expect twice', aggregate_failures: true do
79
+ expect(foo).to eq(bar)
80
+ expect(baz).to eq(bar)
81
+ end
82
+ end
83
+ RUBY
84
+ end
85
+
86
+ it 'checks examples with `aggregate_failures: false`' do
87
+ expect_violation(<<-RUBY)
88
+ describe Foo do
89
+ it 'uses expect twice', aggregate_failures: false do
90
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Example has too many expectations [2/1].
91
+ expect(foo).to eq(bar)
92
+ expect(baz).to eq(bar)
93
+ end
94
+ end
95
+ RUBY
96
+ end
34
97
  end
35
98
 
36
99
  context 'with configuration' do
@@ -53,7 +116,7 @@ describe RuboCop::Cop::RSpec::MultipleExpectations, :config do
53
116
  expect_violation(<<-RUBY)
54
117
  describe Foo do
55
118
  it 'uses expect three times' do
56
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Example has too many expectations [3/2]
119
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Example has too many expectations [3/2].
57
120
  expect(foo).to eq(bar)
58
121
  expect(baz).to eq(bar)
59
122
  expect(qux).to eq(bar)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe RuboCop::Cop::RSpec::NestedGroups, :config do
3
+ RSpec.describe RuboCop::Cop::RSpec::NestedGroups, :config do
4
4
  subject(:cop) { described_class.new(config) }
5
5
 
6
6
  it 'flags nested contexts' do
@@ -9,7 +9,7 @@ describe RuboCop::Cop::RSpec::NestedGroups, :config do
9
9
  context 'when foo' do
10
10
  context 'when bar' do
11
11
  context 'when baz' do
12
- ^^^^^^^^^^^^^^^^^^ Maximum example group nesting exceeded
12
+ ^^^^^^^^^^^^^^^^^^ Maximum example group nesting exceeded [4/3].
13
13
  end
14
14
  end
15
15
  end
@@ -41,9 +41,9 @@ describe RuboCop::Cop::RSpec::NestedGroups, :config do
41
41
  describe MyClass do
42
42
  context 'when foo' do
43
43
  context 'when bar' do
44
- ^^^^^^^^^^^^^^^^^^ Maximum example group nesting exceeded
44
+ ^^^^^^^^^^^^^^^^^^ Maximum example group nesting exceeded [3/2].
45
45
  context 'when baz' do
46
- ^^^^^^^^^^^^^^^^^^ Maximum example group nesting exceeded
46
+ ^^^^^^^^^^^^^^^^^^ Maximum example group nesting exceeded [4/2].
47
47
  end
48
48
  end
49
49
  end
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::NotToNot, :config do
1
+ RSpec.describe RuboCop::Cop::RSpec::NotToNot, :config do
2
2
  subject(:cop) { described_class.new(config) }
3
3
 
4
4
  context 'when EnforcedStyle is `not_to`' do
@@ -7,7 +7,7 @@ describe RuboCop::Cop::RSpec::NotToNot, :config do
7
7
  it 'detects the `to_not` offense' do
8
8
  expect_violation(<<-RUBY)
9
9
  it { expect(false).to_not be_true }
10
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `not_to` over `to_not`
10
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `not_to` over `to_not`.
11
11
  RUBY
12
12
  end
13
13
 
@@ -28,7 +28,7 @@ describe RuboCop::Cop::RSpec::NotToNot, :config do
28
28
  it 'detects the `not_to` offense' do
29
29
  expect_violation(<<-RUBY)
30
30
  it { expect(false).not_to be_true }
31
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `to_not` over `not_to`
31
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `to_not` over `not_to`.
32
32
  RUBY
33
33
  end
34
34