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
@@ -2,7 +2,7 @@ RSpec.describe RuboCop::Cop::RSpec::IteratedExpectation do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'flags `each` with an expectation' do
5
- expect_violation(<<-RUBY)
5
+ expect_offense(<<-RUBY)
6
6
  it 'validates users' do
7
7
  [user1, user2, user3].each { |user| expect(user).to be_valid }
8
8
  ^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using the `all` matcher instead of iterating over an array.
@@ -11,7 +11,7 @@ RSpec.describe RuboCop::Cop::RSpec::IteratedExpectation do
11
11
  end
12
12
 
13
13
  it 'flags `each` when expectation calls method with arguments' do
14
- expect_violation(<<-RUBY)
14
+ expect_offense(<<-RUBY)
15
15
  it 'validates users' do
16
16
  [user1, user2, user3].each { |user| expect(user).to be_a(User) }
17
17
  ^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using the `all` matcher instead of iterating over an array.
@@ -20,7 +20,7 @@ RSpec.describe RuboCop::Cop::RSpec::IteratedExpectation do
20
20
  end
21
21
 
22
22
  it 'ignores `each` without expectation' do
23
- expect_no_violations(<<-RUBY)
23
+ expect_no_offenses(<<-RUBY)
24
24
  it 'validates users' do
25
25
  [user1, user2, user3].each { |user| allow(user).to receive(:method) }
26
26
  end
@@ -28,7 +28,7 @@ RSpec.describe RuboCop::Cop::RSpec::IteratedExpectation do
28
28
  end
29
29
 
30
30
  it 'flags `each` with multiple expectations' do
31
- expect_violation(<<-RUBY)
31
+ expect_offense(<<-RUBY)
32
32
  it 'validates users' do
33
33
  [user1, user2, user3].each do |user|
34
34
  ^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using the `all` matcher instead of iterating over an array.
@@ -40,7 +40,7 @@ RSpec.describe RuboCop::Cop::RSpec::IteratedExpectation do
40
40
  end
41
41
 
42
42
  it 'ignore `each` when the body does not contain only expectations' do
43
- expect_no_violations(<<-RUBY)
43
+ expect_no_offenses(<<-RUBY)
44
44
  it 'validates users' do
45
45
  [user1, user2, user3].each do |user|
46
46
  allow(Something).to receive(:method).and_return(user)
@@ -52,7 +52,7 @@ RSpec.describe RuboCop::Cop::RSpec::IteratedExpectation do
52
52
  end
53
53
 
54
54
  it 'ignores `each` with expectation on property' do
55
- expect_no_violations(<<-RUBY)
55
+ expect_no_offenses(<<-RUBY)
56
56
  it 'validates users' do
57
57
  [user1, user2, user3].each { |user| expect(user.name).to be }
58
58
  end
@@ -60,7 +60,7 @@ RSpec.describe RuboCop::Cop::RSpec::IteratedExpectation do
60
60
  end
61
61
 
62
62
  it 'ignores assignments in the iteration' do
63
- expect_no_violations(<<-RUBY)
63
+ expect_no_offenses(<<-RUBY)
64
64
  it 'validates users' do
65
65
  [user1, user2, user3].each { |user| array = array.concat(user) }
66
66
  end
@@ -68,7 +68,7 @@ RSpec.describe RuboCop::Cop::RSpec::IteratedExpectation do
68
68
  end
69
69
 
70
70
  it 'ignores `each` when there is a negative expectation' do
71
- expect_no_violations(<<-RUBY)
71
+ expect_no_offenses(<<-RUBY)
72
72
  it 'validates users' do
73
73
  [user1, user2, user3].each do |user|
74
74
  expect(user).not_to receive(:method)
@@ -4,7 +4,7 @@ RSpec.describe RuboCop::Cop::RSpec::LeadingSubject do
4
4
  subject(:cop) { described_class.new }
5
5
 
6
6
  it 'checks subject below let' do
7
- expect_violation(<<-RUBY)
7
+ expect_offense(<<-RUBY)
8
8
  RSpec.describe User do
9
9
  let(:params) { foo }
10
10
 
@@ -15,7 +15,7 @@ RSpec.describe RuboCop::Cop::RSpec::LeadingSubject do
15
15
  end
16
16
 
17
17
  it 'checks subject below let!' do
18
- expect_violation(<<-RUBY)
18
+ expect_offense(<<-RUBY)
19
19
  RSpec.describe User do
20
20
  let!(:params) { foo }
21
21
 
@@ -26,7 +26,7 @@ RSpec.describe RuboCop::Cop::RSpec::LeadingSubject do
26
26
  end
27
27
 
28
28
  it 'approves of subject above let' do
29
- expect_no_violations(<<-RUBY)
29
+ expect_no_offenses(<<-RUBY)
30
30
  RSpec.describe User do
31
31
  context 'blah' do
32
32
  end
@@ -39,7 +39,7 @@ RSpec.describe RuboCop::Cop::RSpec::LeadingSubject do
39
39
  end
40
40
 
41
41
  it 'handles subjects in contexts' do
42
- expect_no_violations(<<-RUBY)
42
+ expect_no_offenses(<<-RUBY)
43
43
  RSpec.describe User do
44
44
  let(:params) { foo }
45
45
 
@@ -51,7 +51,7 @@ RSpec.describe RuboCop::Cop::RSpec::LeadingSubject do
51
51
  end
52
52
 
53
53
  it 'handles subjects in tests' do
54
- expect_no_violations(<<-RUBY)
54
+ expect_no_offenses(<<-RUBY)
55
55
  RSpec.describe User do
56
56
  # This shouldn't really ever happen in a sane codebase but I still
57
57
  # want to avoid false positives
@@ -0,0 +1,83 @@
1
+ RSpec.describe RuboCop::Cop::RSpec::LetBeforeExamples do
2
+ subject(:cop) { described_class.new }
3
+
4
+ it 'flags `let` after `it`' do
5
+ expect_offense(<<-RUBY)
6
+ RSpec.describe User do
7
+ it { is_expected.to be_after_let }
8
+ let(:foo) { bar }
9
+ ^^^^^^^^^^^^^^^^^ Move `let` before the examples in the group.
10
+ end
11
+ RUBY
12
+ end
13
+
14
+ it 'flags `let` after `context`' do
15
+ expect_offense(<<-RUBY)
16
+ RSpec.describe User do
17
+ context 'a context' do
18
+ it { is_expected.to be_after_let }
19
+ end
20
+
21
+ let(:foo) { bar }
22
+ ^^^^^^^^^^^^^^^^^ Move `let` before the examples in the group.
23
+ end
24
+ RUBY
25
+ end
26
+
27
+ it 'flags `let` after `include_examples`' do
28
+ expect_offense(<<-RUBY)
29
+ RSpec.describe User do
30
+ include_examples('should be after let')
31
+
32
+ let(:foo) { bar }
33
+ ^^^^^^^^^^^^^^^^^ Move `let` before the examples in the group.
34
+ end
35
+ RUBY
36
+ end
37
+
38
+ it 'does not flag `let` before the examples' do
39
+ expect_no_offenses(<<-RUBY)
40
+ RSpec.describe User do
41
+ let(:foo) { bar }
42
+
43
+ it { is_expected.to be_after_let }
44
+
45
+ context 'a context' do
46
+ it { is_expected.to work }
47
+ end
48
+
49
+ include_examples('everything is fine')
50
+ end
51
+ RUBY
52
+ end
53
+
54
+ it 'does not flag `let` in a nested context' do
55
+ expect_no_offenses(<<-RUBY)
56
+ RSpec.describe User do
57
+ let(:foo) { bar }
58
+
59
+ context 'something else' do
60
+ let(:foo) { baz }
61
+ it { is_expected.to work }
62
+ end
63
+
64
+ include_examples('everything is fine')
65
+ end
66
+ RUBY
67
+ end
68
+
69
+ it 'allows inclusion of context before `let`' do
70
+ expect_no_offenses(<<-RUBY)
71
+ RSpec.describe User do
72
+ include_context 'special user'
73
+
74
+ let(:foo) { bar }
75
+ end
76
+ RUBY
77
+ end
78
+
79
+ it 'does not encounter an error when handling an empty describe' do
80
+ expect { inspect_source(cop, 'RSpec.describe(User) do end', 'a_spec.rb') }
81
+ .not_to raise_error
82
+ end
83
+ end
@@ -4,7 +4,7 @@ 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
7
- expect_violation(<<-RUBY)
7
+ expect_offense(<<-RUBY)
8
8
  describe Foo do
9
9
  let!(:foo) { bar }
10
10
  ^^^^^^^^^^ Do not use `let!` for test setup.
@@ -17,7 +17,7 @@ RSpec.describe RuboCop::Cop::RSpec::LetSetup do
17
17
  end
18
18
 
19
19
  it 'ignores let! when used in `before`' do
20
- expect_no_violations(<<-RUBY)
20
+ expect_no_offenses(<<-RUBY)
21
21
  describe Foo do
22
22
  let!(:foo) { bar }
23
23
 
@@ -33,7 +33,7 @@ RSpec.describe RuboCop::Cop::RSpec::LetSetup do
33
33
  end
34
34
 
35
35
  it 'ignores let! when used in example' do
36
- expect_no_violations(<<-RUBY)
36
+ expect_no_offenses(<<-RUBY)
37
37
  describe Foo do
38
38
  let!(:foo) { bar }
39
39
 
@@ -46,7 +46,7 @@ RSpec.describe RuboCop::Cop::RSpec::LetSetup do
46
46
  end
47
47
 
48
48
  it 'complains when let! is used and not referenced within nested group' do
49
- expect_violation(<<-RUBY)
49
+ expect_offense(<<-RUBY)
50
50
  describe Foo do
51
51
  context 'when something special happens' do
52
52
  let!(:foo) { bar }
@@ -2,7 +2,7 @@ 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
- expect_violation(<<-RUBY)
5
+ expect_offense(<<-RUBY)
6
6
  before do
7
7
  allow(foo).to receive_message_chain(:one, :two) { :three }
8
8
  ^^^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `receive_message_chain`.
@@ -11,7 +11,7 @@ RSpec.describe RuboCop::Cop::RSpec::MessageChain do
11
11
  end
12
12
 
13
13
  it 'finds old `stub_chain` syntax' do
14
- expect_violation(<<-RUBY)
14
+ expect_offense(<<-RUBY)
15
15
  before do
16
16
  foo.stub_chain(:one, :two).and_return(:three)
17
17
  ^^^^^^^^^^ Avoid stubbing using `stub_chain`.
@@ -9,14 +9,14 @@ RSpec.describe RuboCop::Cop::RSpec::MessageExpectation, :config do
9
9
  end
10
10
 
11
11
  it 'flags expect(...).to receive' do
12
- expect_violation(<<-RUBY)
12
+ expect_offense(<<-RUBY)
13
13
  expect(foo).to receive(:bar)
14
14
  ^^^^^^ Prefer `allow` for setting message expectations.
15
15
  RUBY
16
16
  end
17
17
 
18
18
  it 'approves of allow(...).to receive' do
19
- expect_no_violations('allow(foo).to receive(:bar)')
19
+ expect_no_offenses('allow(foo).to receive(:bar)')
20
20
  end
21
21
 
22
22
  include_examples 'detects style', 'allow(foo).to receive(:bar)', 'allow'
@@ -29,14 +29,14 @@ RSpec.describe RuboCop::Cop::RSpec::MessageExpectation, :config do
29
29
  end
30
30
 
31
31
  it 'flags allow(...).to receive' do
32
- expect_violation(<<-RUBY)
32
+ expect_offense(<<-RUBY)
33
33
  allow(foo).to receive(:bar)
34
34
  ^^^^^ Prefer `expect` for setting message expectations.
35
35
  RUBY
36
36
  end
37
37
 
38
38
  it 'approves of expect(...).to receive' do
39
- expect_no_violations('expect(foo).to receive(:bar)')
39
+ expect_no_offenses('expect(foo).to receive(:bar)')
40
40
  end
41
41
 
42
42
  include_examples 'detects style', 'expect(foo).to receive(:bar)', 'expect'
@@ -9,14 +9,14 @@ RSpec.describe RuboCop::Cop::RSpec::MessageSpies, :config do
9
9
  end
10
10
 
11
11
  it 'flags expect(send).to receive' do
12
- expect_violation(<<-RUBY)
12
+ expect_offense(<<-RUBY)
13
13
  expect(foo).to receive(:bar)
14
14
  ^^^^^^^ Prefer `have_received` for setting message expectations. Setup `foo` as a spy using `allow` or `instance_spy`.
15
15
  RUBY
16
16
  end
17
17
 
18
18
  it 'flags expect(lvar).to receive' do
19
- expect_violation(<<-RUBY)
19
+ expect_offense(<<-RUBY)
20
20
  foo = baz
21
21
  expect(foo).to receive(:bar)
22
22
  ^^^^^^^ Prefer `have_received` for setting message expectations. Setup `foo` as a spy using `allow` or `instance_spy`.
@@ -24,49 +24,49 @@ RSpec.describe RuboCop::Cop::RSpec::MessageSpies, :config do
24
24
  end
25
25
 
26
26
  it 'flags expect(ivar).to receive' do
27
- expect_violation(<<-RUBY)
27
+ expect_offense(<<-RUBY)
28
28
  expect(@foo).to receive(:bar)
29
29
  ^^^^^^^ Prefer `have_received` for setting message expectations. Setup `@foo` as a spy using `allow` or `instance_spy`.
30
30
  RUBY
31
31
  end
32
32
 
33
33
  it 'flags expect(const).to receive' do
34
- expect_violation(<<-RUBY)
34
+ expect_offense(<<-RUBY)
35
35
  expect(Foo).to receive(:bar)
36
36
  ^^^^^^^ Prefer `have_received` for setting message expectations. Setup `Foo` as a spy using `allow` or `instance_spy`.
37
37
  RUBY
38
38
  end
39
39
 
40
40
  it 'flags expect(...).not_to receive' do
41
- expect_violation(<<-RUBY)
41
+ expect_offense(<<-RUBY)
42
42
  expect(foo).not_to receive(:bar)
43
43
  ^^^^^^^ Prefer `have_received` for setting message expectations. Setup `foo` as a spy using `allow` or `instance_spy`.
44
44
  RUBY
45
45
  end
46
46
 
47
47
  it 'flags expect(...).to_not receive' do
48
- expect_violation(<<-RUBY)
48
+ expect_offense(<<-RUBY)
49
49
  expect(foo).to_not receive(:bar)
50
50
  ^^^^^^^ Prefer `have_received` for setting message expectations. Setup `foo` as a spy using `allow` or `instance_spy`.
51
51
  RUBY
52
52
  end
53
53
 
54
54
  it 'flags expect(...).to receive with' do
55
- expect_violation(<<-RUBY)
55
+ expect_offense(<<-RUBY)
56
56
  expect(foo).to receive(:bar).with(:baz)
57
57
  ^^^^^^^ Prefer `have_received` for setting message expectations. Setup `foo` as a spy using `allow` or `instance_spy`.
58
58
  RUBY
59
59
  end
60
60
 
61
61
  it 'flags expect(...).to receive at_most' do
62
- expect_violation(<<-RUBY)
62
+ expect_offense(<<-RUBY)
63
63
  expect(foo).to receive(:bar).at_most(42).times
64
64
  ^^^^^^^ Prefer `have_received` for setting message expectations. Setup `foo` as a spy using `allow` or `instance_spy`.
65
65
  RUBY
66
66
  end
67
67
 
68
68
  it 'approves of expect(...).to have_received' do
69
- expect_no_violations('expect(foo).to have_received(:bar)')
69
+ expect_no_offenses('expect(foo).to have_received(:bar)')
70
70
  end
71
71
 
72
72
  include_examples 'detects style', 'expect(foo).to receive(:bar)', 'receive'
@@ -82,14 +82,14 @@ RSpec.describe RuboCop::Cop::RSpec::MessageSpies, :config do
82
82
  end
83
83
 
84
84
  it 'flags expect(send).to have_received' do
85
- expect_violation(<<-RUBY)
85
+ expect_offense(<<-RUBY)
86
86
  expect(foo).to have_received(:bar)
87
87
  ^^^^^^^^^^^^^ Prefer `receive` for setting message expectations.
88
88
  RUBY
89
89
  end
90
90
 
91
91
  it 'flags expect(lvar).to have_received' do
92
- expect_violation(<<-RUBY)
92
+ expect_offense(<<-RUBY)
93
93
  foo = baz
94
94
  expect(foo).to have_received(:bar)
95
95
  ^^^^^^^^^^^^^ Prefer `receive` for setting message expectations.
@@ -97,49 +97,49 @@ RSpec.describe RuboCop::Cop::RSpec::MessageSpies, :config do
97
97
  end
98
98
 
99
99
  it 'flags expect(ivar).to have_received' do
100
- expect_violation(<<-RUBY)
100
+ expect_offense(<<-RUBY)
101
101
  expect(@foo).to have_received(:bar)
102
102
  ^^^^^^^^^^^^^ Prefer `receive` for setting message expectations.
103
103
  RUBY
104
104
  end
105
105
 
106
106
  it 'flags expect(const).to have_received' do
107
- expect_violation(<<-RUBY)
107
+ expect_offense(<<-RUBY)
108
108
  expect(Foo).to have_received(:bar)
109
109
  ^^^^^^^^^^^^^ Prefer `receive` for setting message expectations.
110
110
  RUBY
111
111
  end
112
112
 
113
113
  it 'flags expect(...).not_to have_received' do
114
- expect_violation(<<-RUBY)
114
+ expect_offense(<<-RUBY)
115
115
  expect(foo).not_to have_received(:bar)
116
116
  ^^^^^^^^^^^^^ Prefer `receive` for setting message expectations.
117
117
  RUBY
118
118
  end
119
119
 
120
120
  it 'flags expect(...).to_not have_received' do
121
- expect_violation(<<-RUBY)
121
+ expect_offense(<<-RUBY)
122
122
  expect(foo).to_not have_received(:bar)
123
123
  ^^^^^^^^^^^^^ Prefer `receive` for setting message expectations.
124
124
  RUBY
125
125
  end
126
126
 
127
127
  it 'flags expect(...).to have_received with' do
128
- expect_violation(<<-RUBY)
128
+ expect_offense(<<-RUBY)
129
129
  expect(foo).to have_received(:bar).with(:baz)
130
130
  ^^^^^^^^^^^^^ Prefer `receive` for setting message expectations.
131
131
  RUBY
132
132
  end
133
133
 
134
134
  it 'flags expect(...).to have_received at_most' do
135
- expect_violation(<<-RUBY)
135
+ expect_offense(<<-RUBY)
136
136
  expect(foo).to have_received(:bar).at_most(42).times
137
137
  ^^^^^^^^^^^^^ Prefer `receive` for setting message expectations.
138
138
  RUBY
139
139
  end
140
140
 
141
141
  it 'approves of expect(...).to receive' do
142
- expect_no_violations('expect(foo).to receive(:bar)')
142
+ expect_no_offenses('expect(foo).to receive(:bar)')
143
143
  end
144
144
 
145
145
  include_examples 'detects style', 'expect(foo).to receive(:bar)', 'receive'
@@ -2,7 +2,7 @@ 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
5
- expect_violation(<<-RUBY)
5
+ expect_offense(<<-RUBY)
6
6
  describe MyClass, '.do_something' do; end
7
7
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use multiple top level describes - try to nest them.
8
8
  describe MyClass, '.do_something_else' do; end
@@ -10,7 +10,7 @@ RSpec.describe RuboCop::Cop::RSpec::MultipleDescribes do
10
10
  end
11
11
 
12
12
  it 'finds multiple top level describes only with class' do
13
- expect_violation(<<-RUBY)
13
+ expect_offense(<<-RUBY)
14
14
  describe MyClass do; end
15
15
  ^^^^^^^^^^^^^^^^ Do not use multiple top level describes - try to nest them.
16
16
  describe MyOtherClass do; end
@@ -18,7 +18,7 @@ RSpec.describe RuboCop::Cop::RSpec::MultipleDescribes do
18
18
  end
19
19
 
20
20
  it 'skips single top level describe' do
21
- expect_no_violations(<<-RUBY)
21
+ expect_no_offenses(<<-RUBY)
22
22
  require 'spec_helper'
23
23
 
24
24
  describe MyClass do