rubocop-rspec 1.15.1 → 1.16.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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/Gemfile +0 -1
  4. data/config/default.yml +105 -0
  5. data/lib/rubocop-rspec.rb +27 -0
  6. data/lib/rubocop/cop/rspec/align_left_let_brace.rb +51 -0
  7. data/lib/rubocop/cop/rspec/align_right_let_brace.rb +51 -0
  8. data/lib/rubocop/cop/rspec/any_instance.rb +1 -1
  9. data/lib/rubocop/cop/rspec/cop.rb +4 -2
  10. data/lib/rubocop/cop/rspec/expect_in_hook.rb +61 -0
  11. data/lib/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically.rb +84 -0
  12. data/lib/rubocop/cop/rspec/hook_argument.rb +11 -5
  13. data/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb +42 -0
  14. data/lib/rubocop/cop/rspec/let_before_examples.rb +66 -0
  15. data/lib/rubocop/cop/rspec/multiple_expectations.rb +3 -5
  16. data/lib/rubocop/cop/rspec/multiple_subjects.rb +80 -0
  17. data/lib/rubocop/cop/rspec/named_subject.rb +5 -6
  18. data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
  19. data/lib/rubocop/cop/rspec/predicate_matcher.rb +337 -0
  20. data/lib/rubocop/cop/rspec/return_from_stub.rb +83 -0
  21. data/lib/rubocop/cop/rspec/void_expect.rb +52 -0
  22. data/lib/rubocop/rspec/align_let_brace.rb +64 -0
  23. data/lib/rubocop/rspec/config_formatter.rb +7 -4
  24. data/lib/rubocop/rspec/description_extractor.rb +2 -2
  25. data/lib/rubocop/rspec/example_group.rb +25 -2
  26. data/lib/rubocop/rspec/factory_girl.rb +7 -0
  27. data/lib/rubocop/rspec/language.rb +6 -1
  28. data/lib/rubocop/rspec/version.rb +1 -1
  29. data/rubocop-rspec.gemspec +1 -4
  30. data/spec/project/default_config_spec.rb +8 -4
  31. data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +62 -0
  32. data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +62 -0
  33. data/spec/rubocop/cop/rspec/any_instance_spec.rb +3 -3
  34. data/spec/rubocop/cop/rspec/around_block_spec.rb +11 -11
  35. data/spec/rubocop/cop/rspec/be_eql_spec.rb +7 -7
  36. data/spec/rubocop/cop/rspec/before_after_all_spec.rb +4 -4
  37. data/spec/rubocop/cop/rspec/cop_spec.rb +7 -7
  38. data/spec/rubocop/cop/rspec/describe_class_spec.rb +18 -18
  39. data/spec/rubocop/cop/rspec/describe_method_spec.rb +4 -4
  40. data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +6 -6
  41. data/spec/rubocop/cop/rspec/described_class_spec.rb +18 -18
  42. data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +5 -5
  43. data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +9 -9
  44. data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +5 -5
  45. data/spec/rubocop/cop/rspec/example_length_spec.rb +6 -6
  46. data/spec/rubocop/cop/rspec/example_wording_spec.rb +10 -10
  47. data/spec/rubocop/cop/rspec/expect_actual_spec.rb +10 -10
  48. data/spec/rubocop/cop/rspec/expect_in_hook_spec.rb +79 -0
  49. data/spec/rubocop/cop/rspec/expect_output_spec.rb +7 -7
  50. data/spec/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically_spec.rb +87 -0
  51. data/spec/rubocop/cop/rspec/file_path_spec.rb +29 -29
  52. data/spec/rubocop/cop/rspec/focus_spec.rb +6 -6
  53. data/spec/rubocop/cop/rspec/hook_argument_spec.rb +35 -23
  54. data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +10 -10
  55. data/spec/rubocop/cop/rspec/instance_spy_spec.rb +4 -4
  56. data/spec/rubocop/cop/rspec/instance_variable_spec.rb +7 -7
  57. data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +37 -0
  58. data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +4 -4
  59. data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +8 -8
  60. data/spec/rubocop/cop/rspec/leading_subject_spec.rb +5 -5
  61. data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +83 -0
  62. data/spec/rubocop/cop/rspec/let_setup_spec.rb +4 -4
  63. data/spec/rubocop/cop/rspec/message_chain_spec.rb +2 -2
  64. data/spec/rubocop/cop/rspec/message_expectation_spec.rb +4 -4
  65. data/spec/rubocop/cop/rspec/message_spies_spec.rb +18 -18
  66. data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +3 -3
  67. data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +45 -9
  68. data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +96 -0
  69. data/spec/rubocop/cop/rspec/named_subject_spec.rb +4 -4
  70. data/spec/rubocop/cop/rspec/nested_groups_spec.rb +3 -3
  71. data/spec/rubocop/cop/rspec/not_to_not_spec.rb +4 -4
  72. data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +4 -4
  73. data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +335 -0
  74. data/spec/rubocop/cop/rspec/repeated_description_spec.rb +5 -5
  75. data/spec/rubocop/cop/rspec/repeated_example_spec.rb +5 -5
  76. data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +85 -0
  77. data/spec/rubocop/cop/rspec/scattered_let_spec.rb +2 -2
  78. data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +8 -8
  79. data/spec/rubocop/cop/rspec/shared_context_spec.rb +10 -10
  80. data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +10 -10
  81. data/spec/rubocop/cop/rspec/subject_stub_spec.rb +9 -9
  82. data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +7 -7
  83. data/spec/rubocop/cop/rspec/void_expect_spec.rb +47 -0
  84. data/spec/rubocop/rspec/config_formatter_spec.rb +2 -0
  85. data/spec/spec_helper.rb +1 -1
  86. data/spec/support/expect_offense.rb +17 -0
  87. metadata +39 -51
  88. data/spec/expect_violation/expectation_spec.rb +0 -85
  89. data/spec/support/expect_violation.rb +0 -170
@@ -4,7 +4,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedDescription do
4
4
  subject(:cop) { described_class.new }
5
5
 
6
6
  it 'registers an offense for repeated descriptions' do
7
- expect_violation(<<-RUBY)
7
+ expect_offense(<<-RUBY)
8
8
  describe 'doing x' do
9
9
  it "does x" do
10
10
  ^^^^^^^^^^^ Don't repeat descriptions within an example group.
@@ -18,7 +18,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedDescription do
18
18
  end
19
19
 
20
20
  it 'registers offense for repeated descriptions separated by a context' do
21
- expect_violation(<<-RUBY)
21
+ expect_offense(<<-RUBY)
22
22
  describe 'doing x' do
23
23
  it "does x" do
24
24
  ^^^^^^^^^^^ Don't repeat descriptions within an example group.
@@ -38,7 +38,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedDescription do
38
38
  end
39
39
 
40
40
  it 'ignores descriptions repeated in a shared context' do
41
- expect_no_violations(<<-RUBY)
41
+ expect_no_offenses(<<-RUBY)
42
42
  describe 'doing x' do
43
43
  it "does x" do
44
44
  end
@@ -52,7 +52,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedDescription do
52
52
  end
53
53
 
54
54
  it 'ignores repeated descriptions in a nested context' do
55
- expect_no_violations(<<-RUBY)
55
+ expect_no_offenses(<<-RUBY)
56
56
  describe 'doing x' do
57
57
  it "does x" do
58
58
  end
@@ -66,7 +66,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedDescription do
66
66
  end
67
67
 
68
68
  it 'does not flag tests which do not contain description strings' do
69
- expect_no_violations(<<-RUBY)
69
+ expect_no_offenses(<<-RUBY)
70
70
  describe 'doing x' do
71
71
  it { foo }
72
72
  it { bar }
@@ -4,7 +4,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedExample do
4
4
  subject(:cop) { described_class.new }
5
5
 
6
6
  it 'registers an offense for repeated example' do
7
- expect_violation(<<-RUBY)
7
+ expect_offense(<<-RUBY)
8
8
  describe 'doing x' do
9
9
  it "does x" do
10
10
  ^^^^^^^^^^^^^^ Don't repeat examples within an example group.
@@ -20,7 +20,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedExample do
20
20
  end
21
21
 
22
22
  it 'does not register a violation if rspec tag magic is involved' do
23
- expect_no_violations(<<-RUBY)
23
+ expect_no_offenses(<<-RUBY)
24
24
  describe 'doing x' do
25
25
  it "does x" do
26
26
  expect(foo).to be(bar)
@@ -34,7 +34,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedExample do
34
34
  end
35
35
 
36
36
  it 'does not flag examples with different implementations' do
37
- expect_no_violations(<<-RUBY)
37
+ expect_no_offenses(<<-RUBY)
38
38
  describe 'doing x' do
39
39
  it "does x" do
40
40
  expect(foo).to have_attribute(foo: 1)
@@ -48,7 +48,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedExample do
48
48
  end
49
49
 
50
50
  it 'does not flag examples when different its arguments are used' do
51
- expect_no_violations(<<-RUBY)
51
+ expect_no_offenses(<<-RUBY)
52
52
  describe 'doing x' do
53
53
  its(:x) { is_expected.to be_present }
54
54
  its(:y) { is_expected.to be_present }
@@ -57,7 +57,7 @@ RSpec.describe RuboCop::Cop::RSpec::RepeatedExample do
57
57
  end
58
58
 
59
59
  it 'does not flag repeated examples in different scopes' do
60
- expect_no_violations(<<-RUBY)
60
+ expect_no_offenses(<<-RUBY)
61
61
  describe 'doing x' do
62
62
  it "does x" do
63
63
  expect(foo).to be(bar)
@@ -0,0 +1,85 @@
1
+ RSpec.describe RuboCop::Cop::RSpec::ReturnFromStub, :config do
2
+ subject(:cop) { described_class.new(config) }
3
+
4
+ let(:cop_config) do
5
+ { 'EnforcedStyle' => enforced_style }
6
+ end
7
+
8
+ context 'with EnforcedStyle `and_return`' do
9
+ let(:enforced_style) { 'and_return' }
10
+
11
+ it 'finds static values returned from block' do
12
+ expect_offense(<<-RUBY)
13
+ it do
14
+ allow(Foo).to receive(:bar) { 42 }
15
+ ^^^^^^^^^^^^^^^^^^^^ Use `and_return` for static values.
16
+ end
17
+ RUBY
18
+ end
19
+
20
+ it 'finds array with only static values returned from block' do
21
+ expect_offense(<<-RUBY)
22
+ it do
23
+ allow(Foo).to receive(:bar) { [42, 43] }
24
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `and_return` for static values.
25
+ end
26
+ RUBY
27
+ end
28
+
29
+ it 'ignores dynamic values returned from block' do
30
+ expect_no_offenses(<<-RUBY)
31
+ it do
32
+ allow(Foo).to receive(:bar) { baz }
33
+ end
34
+ RUBY
35
+ end
36
+
37
+ it 'ignores variables return from block' do
38
+ expect_no_offenses(<<-RUBY)
39
+ it do
40
+ $bar = 42
41
+ baz = 123
42
+ allow(Foo).to receive(:bar) { $bar }
43
+ allow(Foo).to receive(:baz) { baz }
44
+ end
45
+ RUBY
46
+ end
47
+
48
+ it 'ignores array with dynamic values returned from block' do
49
+ expect_no_offenses(<<-RUBY)
50
+ it do
51
+ allow(Foo).to receive(:bar) { [42, baz] }
52
+ end
53
+ RUBY
54
+ end
55
+ end
56
+
57
+ context 'with EnforcedStyle `block`' do
58
+ let(:enforced_style) { 'block' }
59
+
60
+ it 'finds static values returned from method' do
61
+ expect_offense(<<-RUBY)
62
+ it do
63
+ allow(Foo).to receive(:bar).and_return(42)
64
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use block for static values.
65
+ end
66
+ RUBY
67
+ end
68
+
69
+ it 'ignores dynamic values returned from method' do
70
+ expect_no_offenses(<<-RUBY)
71
+ it do
72
+ allow(Foo).to receive(:bar).and_return(baz)
73
+ end
74
+ RUBY
75
+ end
76
+
77
+ it 'ignores multiple values being returned from method' do
78
+ expect_no_offenses(<<-RUBY)
79
+ it do
80
+ allow(Foo).to receive(:bar).and_return(42, 43, 44)
81
+ end
82
+ RUBY
83
+ end
84
+ end
85
+ end
@@ -2,7 +2,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredLet do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'flags `let` after the first different node ' do
5
- expect_violation(<<-RUBY)
5
+ expect_offense(<<-RUBY)
6
6
  RSpec.describe User do
7
7
  let(:a) { a }
8
8
  subject { User }
@@ -13,7 +13,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredLet do
13
13
  end
14
14
 
15
15
  it 'doesnt flag `let!` in the middle of multiple `let`s' do
16
- expect_no_violations(<<-RUBY)
16
+ expect_no_offenses(<<-RUBY)
17
17
  RSpec.describe User do
18
18
  subject { User }
19
19
 
@@ -2,7 +2,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredSetup do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'flags multiple hooks in the same example group' do
5
- expect_violation(<<-RUBY)
5
+ expect_offense(<<-RUBY)
6
6
  describe Foo do
7
7
  before { bar }
8
8
  ^^^^^^^^^^^^^^ Do not define multiple hooks in the same example group.
@@ -13,7 +13,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredSetup do
13
13
  end
14
14
 
15
15
  it 'flags multiple hooks of the same scope with different symbols' do
16
- expect_violation(<<-RUBY)
16
+ expect_offense(<<-RUBY)
17
17
  describe Foo do
18
18
  before { bar }
19
19
  ^^^^^^^^^^^^^^ Do not define multiple hooks in the same example group.
@@ -26,7 +26,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredSetup do
26
26
  end
27
27
 
28
28
  it 'flags multiple before(:all) hooks in the same example group' do
29
- expect_violation(<<-RUBY)
29
+ expect_offense(<<-RUBY)
30
30
  describe Foo do
31
31
  before(:all) { bar }
32
32
  ^^^^^^^^^^^^^^^^^^^^ Do not define multiple hooks in the same example group.
@@ -37,7 +37,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredSetup do
37
37
  end
38
38
 
39
39
  it 'does not flag different hooks' do
40
- expect_no_violations(<<-RUBY)
40
+ expect_no_offenses(<<-RUBY)
41
41
  describe Foo do
42
42
  before { bar }
43
43
  after { baz }
@@ -47,7 +47,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredSetup do
47
47
  end
48
48
 
49
49
  it 'does not flag different hook types' do
50
- expect_no_violations(<<-RUBY)
50
+ expect_no_offenses(<<-RUBY)
51
51
  describe Foo do
52
52
  before { bar }
53
53
  before(:all) { baz }
@@ -57,7 +57,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredSetup do
57
57
  end
58
58
 
59
59
  it 'does not flag hooks in different example groups' do
60
- expect_no_violations(<<-RUBY)
60
+ expect_no_offenses(<<-RUBY)
61
61
  describe Foo do
62
62
  before { bar }
63
63
 
@@ -69,7 +69,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredSetup do
69
69
  end
70
70
 
71
71
  it 'does not flag hooks in different shared contexts' do
72
- expect_no_violations(<<-RUBY)
72
+ expect_no_offenses(<<-RUBY)
73
73
  describe Foo do
74
74
  shared_context 'one' do
75
75
  before { bar }
@@ -83,7 +83,7 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredSetup do
83
83
  end
84
84
 
85
85
  it 'does not flag similar method names inside of examples' do
86
- expect_no_violations(<<-RUBY)
86
+ expect_no_offenses(<<-RUBY)
87
87
  describe Foo do
88
88
  before { bar }
89
89
 
@@ -3,14 +3,14 @@ RSpec.describe RuboCop::Cop::RSpec::SharedContext do
3
3
 
4
4
  context 'shared_context' do
5
5
  it 'does not register an offense for empty contexts' do
6
- expect_no_violations(<<-RUBY)
6
+ expect_no_offenses(<<-RUBY)
7
7
  shared_context 'empty' do
8
8
  end
9
9
  RUBY
10
10
  end
11
11
 
12
12
  it 'registers an offense for shared_context with only examples' do
13
- expect_violation(<<-RUBY)
13
+ expect_offense(<<-RUBY)
14
14
  shared_context 'foo' do
15
15
  ^^^^^^^^^^^^^^^^^^^^ Use `shared_examples` when you don't define context.
16
16
  it 'performs actions' do
@@ -20,7 +20,7 @@ RSpec.describe RuboCop::Cop::RSpec::SharedContext do
20
20
  end
21
21
 
22
22
  it 'does not register an offense for `shared_context` with let' do
23
- expect_no_violations(<<-RUBY)
23
+ expect_no_offenses(<<-RUBY)
24
24
  shared_context 'foo' do
25
25
  let(:foo) { :bar }
26
26
 
@@ -31,7 +31,7 @@ RSpec.describe RuboCop::Cop::RSpec::SharedContext do
31
31
  end
32
32
 
33
33
  it 'does not register an offense for `shared_context` with subject' do
34
- expect_no_violations(<<-RUBY)
34
+ expect_no_offenses(<<-RUBY)
35
35
  shared_context 'foo' do
36
36
  subject(:foo) { :bar }
37
37
 
@@ -42,7 +42,7 @@ RSpec.describe RuboCop::Cop::RSpec::SharedContext do
42
42
  end
43
43
 
44
44
  it 'does not register an offense for `shared_context` with before' do
45
- expect_no_violations(<<-RUBY)
45
+ expect_no_offenses(<<-RUBY)
46
46
  shared_context 'foo' do
47
47
  before do
48
48
  something
@@ -57,14 +57,14 @@ RSpec.describe RuboCop::Cop::RSpec::SharedContext do
57
57
 
58
58
  context 'shared_examples' do
59
59
  it 'does not register an offense for empty examples' do
60
- expect_no_violations(<<-RUBY)
60
+ expect_no_offenses(<<-RUBY)
61
61
  shared_examples 'empty' do
62
62
  end
63
63
  RUBY
64
64
  end
65
65
 
66
66
  it 'registers an offense for shared_examples with only let' do
67
- expect_violation(<<-RUBY)
67
+ expect_offense(<<-RUBY)
68
68
  shared_examples 'foo' do
69
69
  ^^^^^^^^^^^^^^^^^^^^^ Use `shared_context` when you don't define examples.
70
70
  let(:foo) { :bar }
@@ -73,7 +73,7 @@ RSpec.describe RuboCop::Cop::RSpec::SharedContext do
73
73
  end
74
74
 
75
75
  it 'registers an offense for shared_examples with only subject' do
76
- expect_violation(<<-RUBY)
76
+ expect_offense(<<-RUBY)
77
77
  shared_examples 'foo' do
78
78
  ^^^^^^^^^^^^^^^^^^^^^ Use `shared_context` when you don't define examples.
79
79
  subject(:foo) { :bar }
@@ -82,7 +82,7 @@ RSpec.describe RuboCop::Cop::RSpec::SharedContext do
82
82
  end
83
83
 
84
84
  it 'registers an offense for shared_examples with only hooks' do
85
- expect_violation(<<-RUBY)
85
+ expect_offense(<<-RUBY)
86
86
  shared_examples 'foo' do
87
87
  ^^^^^^^^^^^^^^^^^^^^^ Use `shared_context` when you don't define examples.
88
88
  before do
@@ -93,7 +93,7 @@ RSpec.describe RuboCop::Cop::RSpec::SharedContext do
93
93
  end
94
94
 
95
95
  it 'does not register an offense for `shared_examples` with it' do
96
- expect_no_violations(<<-RUBY)
96
+ expect_no_offenses(<<-RUBY)
97
97
  shared_examples 'foo' do
98
98
  subject(:foo) { 'foo' }
99
99
  let(:bar) { :baz }
@@ -3,7 +3,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
3
3
 
4
4
  describe 'receive_message_chain' do
5
5
  it 'reports single-argument calls' do
6
- expect_violation(<<-RUBY)
6
+ expect_offense(<<-RUBY)
7
7
  before do
8
8
  allow(foo).to receive_message_chain(:one) { :two }
9
9
  ^^^^^^^^^^^^^^^^^^^^^ Use `receive` instead of calling `receive_message_chain` with a single argument.
@@ -18,7 +18,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
18
18
  )
19
19
 
20
20
  it 'accepts multi-argument calls' do
21
- expect_no_violations(<<-RUBY)
21
+ expect_no_offenses(<<-RUBY)
22
22
  before do
23
23
  allow(foo).to receive_message_chain(:one, :two) { :three }
24
24
  end
@@ -26,7 +26,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
26
26
  end
27
27
 
28
28
  it 'reports single-argument string calls' do
29
- expect_violation(<<-RUBY)
29
+ expect_offense(<<-RUBY)
30
30
  before do
31
31
  allow(foo).to receive_message_chain("one") { :two }
32
32
  ^^^^^^^^^^^^^^^^^^^^^ Use `receive` instead of calling `receive_message_chain` with a single argument.
@@ -41,7 +41,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
41
41
  )
42
42
 
43
43
  it 'accepts multi-argument string calls' do
44
- expect_no_violations(<<-RUBY)
44
+ expect_no_offenses(<<-RUBY)
45
45
  before do
46
46
  allow(foo).to receive_message_chain("one.two") { :three }
47
47
  end
@@ -50,7 +50,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
50
50
 
51
51
  context 'with single-key hash argument' do
52
52
  it 'reports an offence' do
53
- expect_violation(<<-RUBY)
53
+ expect_offense(<<-RUBY)
54
54
  before do
55
55
  allow(foo).to receive_message_chain(bar: 42)
56
56
  ^^^^^^^^^^^^^^^^^^^^^ Use `receive` instead of calling `receive_message_chain` with a single argument.
@@ -79,7 +79,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
79
79
 
80
80
  context 'with multiple keys hash argument' do
81
81
  it "doesn't report an offence" do
82
- expect_no_violations(<<-RUBY)
82
+ expect_no_offenses(<<-RUBY)
83
83
  before do
84
84
  allow(foo).to receive_message_chain(bar: 42, baz: 42)
85
85
  end
@@ -90,7 +90,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
90
90
 
91
91
  describe 'stub_chain' do
92
92
  it 'reports single-argument calls' do
93
- expect_violation(<<-RUBY)
93
+ expect_offense(<<-RUBY)
94
94
  before do
95
95
  foo.stub_chain(:one) { :two }
96
96
  ^^^^^^^^^^ Use `stub` instead of calling `stub_chain` with a single argument.
@@ -105,7 +105,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
105
105
  )
106
106
 
107
107
  it 'accepts multi-argument calls' do
108
- expect_no_violations(<<-RUBY)
108
+ expect_no_offenses(<<-RUBY)
109
109
  before do
110
110
  foo.stub_chain(:one, :two) { :three }
111
111
  end
@@ -113,7 +113,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
113
113
  end
114
114
 
115
115
  it 'reports single-argument string calls' do
116
- expect_violation(<<-RUBY)
116
+ expect_offense(<<-RUBY)
117
117
  before do
118
118
  foo.stub_chain("one") { :two }
119
119
  ^^^^^^^^^^ Use `stub` instead of calling `stub_chain` with a single argument.
@@ -128,7 +128,7 @@ RSpec.describe RuboCop::Cop::RSpec::SingleArgumentMessageChain do
128
128
  )
129
129
 
130
130
  it 'accepts multi-argument string calls' do
131
- expect_no_violations(<<-RUBY)
131
+ expect_no_offenses(<<-RUBY)
132
132
  before do
133
133
  foo.stub_chain("one.two") { :three }
134
134
  end
@@ -4,7 +4,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
4
4
  subject(:cop) { described_class.new }
5
5
 
6
6
  it 'complains when subject is stubbed' do
7
- expect_violation(<<-RUBY)
7
+ expect_offense(<<-RUBY)
8
8
  describe Foo do
9
9
  subject(:foo) { described_class.new }
10
10
 
@@ -21,7 +21,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
21
21
  end
22
22
 
23
23
  it 'complains when subject is mocked' do
24
- expect_violation(<<-RUBY)
24
+ expect_offense(<<-RUBY)
25
25
  describe Foo do
26
26
  subject(:foo) { described_class.new }
27
27
 
@@ -44,7 +44,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
44
44
  end
45
45
 
46
46
  it 'ignores stub within context where subject name changed' do
47
- expect_no_violations(<<-RUBY)
47
+ expect_no_offenses(<<-RUBY)
48
48
  describe Foo do
49
49
  subject(:foo) { described_class.new }
50
50
 
@@ -60,7 +60,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
60
60
  end
61
61
 
62
62
  it 'flags nested subject stubs when nested subject uses same name' do
63
- expect_violation(<<-RUBY)
63
+ expect_offense(<<-RUBY)
64
64
  describe Foo do
65
65
  subject(:foo) { described_class.new }
66
66
 
@@ -81,7 +81,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
81
81
  end
82
82
 
83
83
  it 'ignores nested stubs when nested subject is anonymous' do
84
- expect_no_violations(<<-RUBY)
84
+ expect_no_offenses(<<-RUBY)
85
85
  describe Foo do
86
86
  subject(:foo) { described_class.new }
87
87
 
@@ -101,7 +101,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
101
101
  end
102
102
 
103
103
  it 'flags nested subject stubs when example group does not define subject' do
104
- expect_violation(<<-RUBY)
104
+ expect_offense(<<-RUBY)
105
105
  describe Foo do
106
106
  subject(:foo) { described_class.new }
107
107
 
@@ -120,7 +120,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
120
120
  end
121
121
 
122
122
  it 'flags nested subject stubs' do
123
- expect_violation(<<-RUBY)
123
+ expect_offense(<<-RUBY)
124
124
  describe Foo do
125
125
  subject(:foo) { described_class.new }
126
126
 
@@ -142,7 +142,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
142
142
  end
143
143
 
144
144
  it 'flags nested subject stubs when adjacent context redefines' do
145
- expect_violation(<<-RUBY)
145
+ expect_offense(<<-RUBY)
146
146
  describe Foo do
147
147
  subject(:foo) { described_class.new }
148
148
 
@@ -159,7 +159,7 @@ RSpec.describe RuboCop::Cop::RSpec::SubjectStub do
159
159
  end
160
160
 
161
161
  it 'flags deeply nested subject stubs' do
162
- expect_violation(<<-RUBY)
162
+ expect_offense(<<-RUBY)
163
163
  describe Foo do
164
164
  subject(:foo) { described_class.new }
165
165