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,30 +1,119 @@
1
- describe RuboCop::Cop::RSpec::AroundBlock do
1
+ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
- it 'finds `around` block without block arguments' do
5
- expect_violation(<<-RUBY)
6
- around do
7
- ^^^^^^^^^ Test object should be passed to around block
8
- do_something
9
- end
10
- RUBY
11
- end
12
-
13
- it 'finds `around` block with unused argument' do
14
- expect_violation(<<-RUBY)
15
- around do |test|
16
- ^^^^ You should call `test.call` or `test.run`
17
- do_something
18
- end
19
- RUBY
20
- end
21
-
22
- it 'checks the first argument of the block' do
23
- expect_violation(<<-RUBY)
24
- around do |test, unused|
25
- ^^^^ You should call `test.call` or `test.run`
26
- unused.run
27
- end
28
- RUBY
4
+ context 'when no value is yielded' do
5
+ it 'registers an offense' do
6
+ expect_violation(<<-RUBY)
7
+ around do
8
+ ^^^^^^^^^ Test object should be passed to around block.
9
+ do_something
10
+ end
11
+ RUBY
12
+ end
13
+ end
14
+
15
+ context 'when the hook is scoped with a symbol' do
16
+ it 'registers an offense' do
17
+ expect_violation(<<-RUBY)
18
+ around(:each) do
19
+ ^^^^^^^^^^^^^^^^ Test object should be passed to around block.
20
+ do_something
21
+ end
22
+ RUBY
23
+ end
24
+ end
25
+
26
+ context 'when the yielded value is unused' do
27
+ it 'registers an offense' do
28
+ expect_violation(<<-RUBY)
29
+ around do |test|
30
+ ^^^^ You should call `test.call` or `test.run`.
31
+ do_something
32
+ end
33
+ RUBY
34
+ end
35
+ end
36
+
37
+ context 'when two values are yielded and the first is unused' do
38
+ it 'registers an offense for the first argument' do
39
+ expect_violation(<<-RUBY)
40
+ around do |test, unused|
41
+ ^^^^ You should call `test.call` or `test.run`.
42
+ unused.run
43
+ end
44
+ RUBY
45
+ end
46
+ end
47
+
48
+ context 'when the yielded value is referenced but not used' do
49
+ it 'registers an offense' do
50
+ expect_violation(<<-RUBY)
51
+ around do |test|
52
+ ^^^^ You should call `test.call` or `test.run`.
53
+ test
54
+ end
55
+ RUBY
56
+ end
57
+ end
58
+
59
+ context 'when a method other than #run or #call is called' do
60
+ it 'registers an offense' do
61
+ expect_violation(<<-RUBY)
62
+ around do |test|
63
+ ^^^^ You should call `test.call` or `test.run`.
64
+ test.inspect
65
+ end
66
+ RUBY
67
+ end
68
+ end
69
+
70
+ context 'when #run is called' do
71
+ it 'does not register an offense' do
72
+ expect_no_violations(<<-RUBY)
73
+ around do |test|
74
+ test.run
75
+ end
76
+ RUBY
77
+ end
78
+ end
79
+
80
+ context 'when #call is called' do
81
+ it 'does not register an offense' do
82
+ expect_no_violations(<<-RUBY)
83
+ around do |test|
84
+ test.call
85
+ end
86
+ RUBY
87
+ end
88
+ end
89
+
90
+ context 'when used as a block arg' do
91
+ it 'does not register an offense' do
92
+ expect_no_violations(<<-RUBY)
93
+ around do |test|
94
+ 1.times(&test)
95
+ end
96
+ RUBY
97
+ end
98
+ end
99
+
100
+ context 'when passed to another method' do
101
+ it 'does not register an offense' do
102
+ expect_no_violations(<<-RUBY)
103
+ around do |test|
104
+ something_that_might_run_test(test, another_arg)
105
+ end
106
+ RUBY
107
+ end
108
+ end
109
+
110
+ context 'when yielded to another block' do
111
+ it 'does not register an offense' do
112
+ expect_no_violations(<<-RUBY)
113
+ around do |test|
114
+ foo { yield(some_arg, test) }
115
+ end
116
+ RUBY
117
+ end
29
118
  end
30
119
  end
@@ -1,44 +1,44 @@
1
- describe RuboCop::Cop::RSpec::BeEql do
1
+ RSpec.describe RuboCop::Cop::RSpec::BeEql do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'registers an offense for `eql` when argument is a boolean' do
5
5
  expect_violation(<<-RUBY)
6
6
  it { expect(foo).to eql(true) }
7
- ^^^ Prefer `be` over `eql`
7
+ ^^^ Prefer `be` over `eql`.
8
8
  it { expect(foo).to eql(false) }
9
- ^^^ Prefer `be` over `eql`
9
+ ^^^ Prefer `be` over `eql`.
10
10
  RUBY
11
11
  end
12
12
 
13
13
  it 'registers an offense for `eql` when argument is an integer' do
14
14
  expect_violation(<<-RUBY)
15
15
  it { expect(foo).to eql(0) }
16
- ^^^ Prefer `be` over `eql`
16
+ ^^^ Prefer `be` over `eql`.
17
17
  it { expect(foo).to eql(123) }
18
- ^^^ Prefer `be` over `eql`
18
+ ^^^ Prefer `be` over `eql`.
19
19
  RUBY
20
20
  end
21
21
 
22
22
  it 'registers an offense for `eql` when argument is a float' do
23
23
  expect_violation(<<-RUBY)
24
24
  it { expect(foo).to eql(1.0) }
25
- ^^^ Prefer `be` over `eql`
25
+ ^^^ Prefer `be` over `eql`.
26
26
  it { expect(foo).to eql(1.23) }
27
- ^^^ Prefer `be` over `eql`
27
+ ^^^ Prefer `be` over `eql`.
28
28
  RUBY
29
29
  end
30
30
 
31
31
  it 'registers an offense for `eql` when argument is a symbol' do
32
32
  expect_violation(<<-RUBY)
33
33
  it { expect(foo).to eql(:foo) }
34
- ^^^ Prefer `be` over `eql`
34
+ ^^^ Prefer `be` over `eql`.
35
35
  RUBY
36
36
  end
37
37
 
38
38
  it 'registers an offense for `eql` when argument is nil' do
39
39
  expect_violation(<<-RUBY)
40
40
  it { expect(foo).to eql(nil) }
41
- ^^^ Prefer `be` over `eql`
41
+ ^^^ Prefer `be` over `eql`.
42
42
  RUBY
43
43
  end
44
44
 
@@ -1,92 +1,50 @@
1
- describe RuboCop::Cop::RSpec::BeforeAfterAll, :config do
1
+ RSpec.describe RuboCop::Cop::RSpec::BeforeAfterAll, :config do
2
2
  subject(:cop) { described_class.new(config) }
3
3
 
4
- context 'when offenses detected' do
5
- let(:code) do
6
- [
7
- 'describe MyClass do',
8
- ' before(:all) { do_something}',
9
- ' after(:all) { do_something_else }',
10
- 'end'
11
- ]
12
- end
13
-
14
- let(:expected_error) do
15
- 'Beware of using `before/after(:all)` as it may cause state to leak '\
16
- 'between tests. If you are using rspec-rails, and '\
17
- '`use_transactional_fixtures` is enabled, then records created in '\
18
- '`before(:all)` are not rolled back.'
19
- end
20
-
21
- it 'reports 2 offenses' do
22
- inspect_source(cop, code, 'foo_spec.rb')
23
- expect(cop.offenses.size).to eq(2)
24
- end
25
-
26
- it 'reports the lines for these offenses' do
27
- inspect_source(cop, code, 'foo_spec.rb')
28
- expect(cop.offenses.map(&:line).sort).to eq([2, 3])
29
- end
30
-
31
- it 'describes the offenses' do
32
- inspect_source(cop, code, 'foo_spec.rb')
33
- expect(cop.messages).to eq([expected_error, expected_error])
34
- end
4
+ def message(hook)
5
+ "Beware of using `#{hook}` as it may cause state to leak between tests. "\
6
+ 'If you are using `rspec-rails`, and `use_transactional_fixtures` is '\
7
+ "enabled, then records created in `#{hook}` are not automatically rolled "\
8
+ 'back.'
35
9
  end
36
10
 
37
- it 'complains for :context' do
38
- inspect_source(
39
- cop,
40
- [
41
- 'describe MyClass do',
42
- ' before(:context) { do_something }',
43
- ' after(:context) { do_something_else }',
44
- 'end'
45
- ],
46
- 'foo_spec.rb'
47
- )
48
- expect(cop.offenses.size).to eq(2)
11
+ context 'when using before all' do
12
+ it 'registers an offense' do
13
+ expect_violation(<<-RUBY)
14
+ before(:all) { do_something }
15
+ ^^^^^^^^^^^^ #{message('before(:all)')}
16
+ before(:context) { do_something }
17
+ ^^^^^^^^^^^^^^^^ #{message('before(:context)')}
18
+ RUBY
19
+ end
49
20
  end
50
21
 
51
- it 'does not complain for before/after :each' do
52
- inspect_source(
53
- cop,
54
- [
55
- 'describe MyClass do',
56
- ' before(:each) { do_something }',
57
- ' after(:each) { do_something_else }',
58
- 'end'
59
- ],
60
- 'foo_spec.rb'
61
- )
62
- expect(cop.offenses).to be_empty
22
+ context 'when using after all' do
23
+ it 'registers an offense' do
24
+ expect_violation(<<-RUBY)
25
+ after(:all) { do_something }
26
+ ^^^^^^^^^^^ #{message('after(:all)')}
27
+ after(:context) { do_something }
28
+ ^^^^^^^^^^^^^^^ #{message('after(:context)')}
29
+ RUBY
30
+ end
63
31
  end
64
32
 
65
- it 'does not complain for before/after :example' do
66
- inspect_source(
67
- cop,
68
- [
69
- 'describe MyClass do',
70
- ' before(:example) { do_something }',
71
- ' after(:example) { do_something_else }',
72
- 'end'
73
- ],
74
- 'foo_spec.rb'
75
- )
76
- expect(cop.offenses).to be_empty
33
+ context 'when using before each' do
34
+ it 'does not register an offense' do
35
+ expect_no_violations(<<-RUBY)
36
+ before(:each) { do_something }
37
+ before(:example) { do_something }
38
+ RUBY
39
+ end
77
40
  end
78
41
 
79
- it 'does not complain for before/after' do
80
- inspect_source(
81
- cop,
82
- [
83
- 'describe MyClass do',
84
- ' before { do_something }',
85
- ' after { do_something_else }',
86
- 'end'
87
- ],
88
- 'foo_spec.rb'
89
- )
90
- expect(cop.offenses).to be_empty
42
+ context 'when using after each' do
43
+ it 'does not register an offense' do
44
+ expect_no_violations(<<-RUBY)
45
+ after(:each) { do_something }
46
+ after(:example) { do_something }
47
+ RUBY
48
+ end
91
49
  end
92
50
  end
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::DescribeClass do
1
+ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'checks first-line describe statements' do
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::DescribeMethod do
1
+ RSpec.describe RuboCop::Cop::RSpec::DescribeMethod do
2
2
  subject(:cop) { described_class.new }
3
3
 
4
4
  it 'ignores describes with only a class' do
@@ -8,7 +8,7 @@ describe RuboCop::Cop::RSpec::DescribeMethod do
8
8
  it 'enforces non-method names' do
9
9
  expect_violation(<<-RUBY)
10
10
  describe Some::Class, 'nope', '.incorrect_usage' do
11
- ^^^^^^ The second argument to describe should be the method being tested. '#instance' or '.class'
11
+ ^^^^^^ The second argument to describe should be the method being tested. '#instance' or '.class'.
12
12
  end
13
13
  RUBY
14
14
  end
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::DescribedClass, :config do
1
+ RSpec.describe RuboCop::Cop::RSpec::DescribedClass, :config do
2
2
  subject(:cop) { described_class.new(config) }
3
3
 
4
4
  let(:cop_config) do
@@ -15,7 +15,7 @@ describe RuboCop::Cop::RSpec::DescribedClass, :config do
15
15
 
16
16
  before do
17
17
  MyClass
18
- ^^^^^^^ Use `described_class` instead of `MyClass`
18
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
19
19
 
20
20
  Foo.custom_block do
21
21
  MyClass
@@ -32,16 +32,16 @@ describe RuboCop::Cop::RSpec::DescribedClass, :config do
32
32
  describe MyClass do
33
33
  controller(ApplicationController) do
34
34
  bar = MyClass
35
- ^^^^^^^ Use `described_class` instead of `MyClass`
35
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
36
36
  end
37
37
 
38
38
  before(:each) do
39
39
  MyClass
40
- ^^^^^^^ Use `described_class` instead of `MyClass`
40
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
41
41
 
42
42
  Foo.custom_block do
43
43
  MyClass
44
- ^^^^^^^ Use `described_class` instead of `MyClass`
44
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
45
45
  end
46
46
  end
47
47
  end
@@ -80,13 +80,13 @@ describe RuboCop::Cop::RSpec::DescribedClass, :config do
80
80
  expect_violation(<<-RUBY)
81
81
  describe MyClass do
82
82
  include MyClass
83
- ^^^^^^^ Use `described_class` instead of `MyClass`
83
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
84
84
 
85
85
  subject { MyClass.do_something }
86
- ^^^^^^^ Use `described_class` instead of `MyClass`
86
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
87
87
 
88
88
  before { MyClass.do_something }
89
- ^^^^^^^ Use `described_class` instead of `MyClass`
89
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
90
90
  end
91
91
  RUBY
92
92
  end
@@ -135,7 +135,7 @@ describe RuboCop::Cop::RSpec::DescribedClass, :config do
135
135
  subject { MyClass::Foo }
136
136
 
137
137
  let(:foo) { MyClass }
138
- ^^^^^^^ Use `described_class` instead of `MyClass`
138
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
139
139
  end
140
140
  end
141
141
  RUBY
@@ -162,7 +162,7 @@ describe RuboCop::Cop::RSpec::DescribedClass, :config do
162
162
  expect_violation(<<-RUBY)
163
163
  describe MyNamespace::MyClass do
164
164
  subject { MyNamespace::MyClass }
165
- ^^^^^^^^^^^^^^^^^^^^ Use `described_class` instead of `MyNamespace::MyClass`
165
+ ^^^^^^^^^^^^^^^^^^^^ Use `described_class` instead of `MyNamespace::MyClass`.
166
166
  end
167
167
  RUBY
168
168
  end
@@ -222,13 +222,13 @@ describe RuboCop::Cop::RSpec::DescribedClass, :config do
222
222
  expect_violation(<<-RUBY)
223
223
  describe MyClass do
224
224
  include described_class
225
- ^^^^^^^^^^^^^^^ Use `MyClass` instead of `described_class`
225
+ ^^^^^^^^^^^^^^^ Use `MyClass` instead of `described_class`.
226
226
 
227
227
  subject { described_class.do_something }
228
- ^^^^^^^^^^^^^^^ Use `MyClass` instead of `described_class`
228
+ ^^^^^^^^^^^^^^^ Use `MyClass` instead of `described_class`.
229
229
 
230
230
  before { described_class.do_something }
231
- ^^^^^^^^^^^^^^^ Use `MyClass` instead of `described_class`
231
+ ^^^^^^^^^^^^^^^ Use `MyClass` instead of `described_class`.
232
232
  end
233
233
  RUBY
234
234
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe RuboCop::Cop::RSpec::EmptyExampleGroup, :config do
3
+ RSpec.describe RuboCop::Cop::RSpec::EmptyExampleGroup, :config do
4
4
  subject(:cop) { described_class.new(config) }
5
5
 
6
6
  it 'flags an empty context' do
@@ -1,4 +1,4 @@
1
- describe RuboCop::Cop::RSpec::ExampleLength, :config do
1
+ RSpec.describe RuboCop::Cop::RSpec::ExampleLength, :config do
2
2
  subject(:cop) { described_class.new(config) }
3
3
 
4
4
  let(:cop_config) { { 'Max' => 3 } }
@@ -42,29 +42,11 @@ describe RuboCop::Cop::RSpec::ExampleLength, :config do
42
42
  RUBY
43
43
  end
44
44
 
45
- shared_examples 'large example violation' do
46
- before do
47
- inspect_source(cop, source, 'spec/foo_spec.rb')
48
- end
49
-
50
- it 'flags an offense' do
51
- expect(cop.offenses.size).to eq(1)
52
- end
53
-
54
- it 'registers the offense on line 1' do
55
- expect(cop.offenses.map(&:line)).to eq([1])
56
- end
57
-
58
- it 'adds a message saying the example has too many lines' do
59
- expect(cop.messages).to eq(['Example has too many lines. [4/3]'])
60
- end
61
- end
62
-
63
45
  context 'when inspecting large examples' do
64
46
  it 'flags the example' do
65
47
  expect_violation(<<-RUBY)
66
48
  it do
67
- ^^^^^ Example has too many lines. [4/3]
49
+ ^^^^^ Example has too many lines [4/3].
68
50
  line 1
69
51
  line 2
70
52
  line 3
@@ -79,21 +61,10 @@ describe RuboCop::Cop::RSpec::ExampleLength, :config do
79
61
  { 'Max' => 3, 'CountComments' => true }
80
62
  end
81
63
 
82
- let(:source) do
83
- [
84
- 'it do',
85
- ' line 1',
86
- ' line 2',
87
- ' # comment',
88
- ' line 3',
89
- 'end'
90
- ]
91
- end
92
-
93
64
  it 'flags the example' do
94
65
  expect_violation(<<-RUBY)
95
66
  it do
96
- ^^^^^ Example has too many lines. [4/3]
67
+ ^^^^^ Example has too many lines [4/3].
97
68
  line 1
98
69
  line 2
99
70
  # comment