rubocop-rspec 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +23 -0
  4. data/Rakefile +19 -1
  5. data/config/default.yml +78 -15
  6. data/lib/rubocop-rspec.rb +19 -1
  7. data/lib/rubocop/cop/rspec/any_instance.rb +5 -1
  8. data/lib/rubocop/cop/rspec/be_eql.rb +58 -0
  9. data/lib/rubocop/cop/rspec/describe_class.rb +2 -3
  10. data/lib/rubocop/cop/rspec/describe_method.rb +4 -3
  11. data/lib/rubocop/cop/rspec/described_class.rb +4 -35
  12. data/lib/rubocop/cop/rspec/empty_example_group.rb +100 -0
  13. data/lib/rubocop/cop/rspec/example_length.rb +5 -2
  14. data/lib/rubocop/cop/rspec/example_wording.rb +5 -2
  15. data/lib/rubocop/cop/rspec/expect_actual.rb +79 -0
  16. data/lib/rubocop/cop/rspec/file_path.rb +3 -1
  17. data/lib/rubocop/cop/rspec/focus.rb +12 -28
  18. data/lib/rubocop/cop/rspec/hook_argument.rb +122 -0
  19. data/lib/rubocop/cop/rspec/instance_variable.rb +53 -12
  20. data/lib/rubocop/cop/rspec/leading_subject.rb +58 -0
  21. data/lib/rubocop/cop/rspec/let_setup.rb +58 -0
  22. data/lib/rubocop/cop/rspec/message_chain.rb +33 -0
  23. data/lib/rubocop/cop/rspec/message_expectation.rb +58 -0
  24. data/lib/rubocop/cop/rspec/multiple_describes.rb +10 -7
  25. data/lib/rubocop/cop/rspec/multiple_expectations.rb +89 -0
  26. data/lib/rubocop/cop/rspec/named_subject.rb +10 -1
  27. data/lib/rubocop/cop/rspec/nested_groups.rb +125 -0
  28. data/lib/rubocop/cop/rspec/not_to_not.rb +3 -3
  29. data/lib/rubocop/cop/rspec/subject_stub.rb +136 -0
  30. data/lib/rubocop/cop/rspec/verified_doubles.rb +4 -1
  31. data/lib/rubocop/rspec.rb +10 -0
  32. data/lib/rubocop/rspec/config_formatter.rb +33 -0
  33. data/lib/rubocop/rspec/description_extractor.rb +35 -0
  34. data/lib/rubocop/rspec/inject.rb +2 -6
  35. data/lib/rubocop/rspec/language.rb +73 -0
  36. data/lib/rubocop/rspec/language/node_pattern.rb +16 -0
  37. data/lib/rubocop/rspec/spec_only.rb +61 -0
  38. data/lib/rubocop/rspec/top_level_describe.rb +6 -0
  39. data/lib/rubocop/rspec/version.rb +1 -1
  40. data/rubocop-rspec.gemspec +1 -0
  41. data/spec/project/changelog_spec.rb +81 -0
  42. data/spec/project/default_config_spec.rb +52 -0
  43. data/spec/project/project_requires_spec.rb +8 -0
  44. data/spec/rubocop/cop/rspec/be_eql_spec.rb +59 -0
  45. data/spec/rubocop/cop/rspec/described_class_spec.rb +2 -2
  46. data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +79 -0
  47. data/spec/rubocop/cop/rspec/example_length_spec.rb +50 -30
  48. data/spec/rubocop/cop/rspec/example_wording_spec.rb +21 -3
  49. data/spec/rubocop/cop/rspec/expect_actual_spec.rb +136 -0
  50. data/spec/rubocop/cop/rspec/file_path_spec.rb +48 -71
  51. data/spec/rubocop/cop/rspec/focus_spec.rb +1 -1
  52. data/spec/rubocop/cop/rspec/hook_argument_spec.rb +189 -0
  53. data/spec/rubocop/cop/rspec/instance_variable_spec.rb +37 -0
  54. data/spec/rubocop/cop/rspec/leading_subject_spec.rb +54 -0
  55. data/spec/rubocop/cop/rspec/let_setup_spec.rb +66 -0
  56. data/spec/rubocop/cop/rspec/message_chain_spec.rb +21 -0
  57. data/spec/rubocop/cop/rspec/message_expectation_spec.rb +63 -0
  58. data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +84 -0
  59. data/spec/rubocop/cop/rspec/nested_groups_spec.rb +55 -0
  60. data/spec/rubocop/cop/rspec/not_to_not_spec.rb +12 -2
  61. data/spec/rubocop/cop/rspec/subject_stub_spec.rb +183 -0
  62. data/spec/rubocop/rspec/config_formatter_spec.rb +48 -0
  63. data/spec/rubocop/rspec/description_extractor_spec.rb +35 -0
  64. data/spec/rubocop/rspec/language/selector_set_spec.rb +29 -0
  65. data/spec/rubocop/rspec/spec_only_spec.rb +97 -0
  66. data/spec/shared/rspec_only_cop_behavior.rb +68 -0
  67. data/spec/spec_helper.rb +13 -1
  68. metadata +72 -5
  69. data/spec/project_spec.rb +0 -115
@@ -45,19 +45,37 @@ describe RuboCop::Cop::RSpec::ExampleWording, :config do
45
45
  end
46
46
 
47
47
  it 'corrects `it "should only have"` to it "only has"' do
48
- corrected = autocorrect_source(cop, 'it "should only have trait" do end')
48
+ corrected =
49
+ autocorrect_source(
50
+ cop,
51
+ 'it "should only have trait" do end',
52
+ 'spec/foo_spec.rb'
53
+ )
54
+
49
55
  expect(corrected).to eql('it "only has trait" do end')
50
56
  end
51
57
  end
52
58
 
53
59
  context 'when configuration is empty' do
54
60
  it 'only does not correct "have"' do
55
- corrected = autocorrect_source(cop, 'it "should have trait" do end')
61
+ corrected =
62
+ autocorrect_source(
63
+ cop,
64
+ 'it "should have trait" do end',
65
+ 'spec/foo_spec.rb'
66
+ )
67
+
56
68
  expect(corrected).to eql('it "haves trait" do end')
57
69
  end
58
70
 
59
71
  it 'only does not make an exception for the word "only"' do
60
- corrected = autocorrect_source(cop, 'it "should only fail" do end')
72
+ corrected =
73
+ autocorrect_source(
74
+ cop,
75
+ 'it "should only fail" do end',
76
+ 'spec/foo_spec.rb'
77
+ )
78
+
61
79
  expect(corrected).to eql('it "onlies fail" do end')
62
80
  end
63
81
  end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe RuboCop::Cop::RSpec::ExpectActual do
4
+ subject(:cop) { described_class.new }
5
+
6
+ it 'flags numeric literal values within expect(...)' do
7
+ expect_violation(<<-RUBY)
8
+ describe Foo do
9
+ it 'uses expect incorrectly' do
10
+ expect(123).to eq(bar)
11
+ ^^^ Provide the actual you are testing to `expect(...)`
12
+ expect(12.3).to eq(bar)
13
+ ^^^^ Provide the actual you are testing to `expect(...)`
14
+ expect(1i).to eq(bar)
15
+ ^^ Provide the actual you are testing to `expect(...)`
16
+ expect(1r).to eq(bar)
17
+ ^^ Provide the actual you are testing to `expect(...)`
18
+ end
19
+ end
20
+ RUBY
21
+ end
22
+
23
+ it 'flags boolean literal values within expect(...)' do
24
+ expect_violation(<<-RUBY)
25
+ describe Foo do
26
+ it 'uses expect incorrectly' do
27
+ expect(true).to eq(bar)
28
+ ^^^^ Provide the actual you are testing to `expect(...)`
29
+ expect(false).to eq(bar)
30
+ ^^^^^ Provide the actual you are testing to `expect(...)`
31
+ end
32
+ end
33
+ RUBY
34
+ end
35
+
36
+ it 'flags string and symbol literal values within expect(...)' do
37
+ expect_violation(<<-RUBY)
38
+ describe Foo do
39
+ it 'uses expect incorrectly' do
40
+ expect("foo").to eq(bar)
41
+ ^^^^^ Provide the actual you are testing to `expect(...)`
42
+ expect(:foo).to eq(bar)
43
+ ^^^^ Provide the actual you are testing to `expect(...)`
44
+ end
45
+ end
46
+ RUBY
47
+ end
48
+
49
+ it 'flags literal nil value within expect(...)' do
50
+ expect_violation(<<-RUBY)
51
+ describe Foo do
52
+ it 'uses expect incorrectly' do
53
+ expect(nil).to eq(bar)
54
+ ^^^ Provide the actual you are testing to `expect(...)`
55
+ end
56
+ end
57
+ RUBY
58
+ end
59
+
60
+ it 'does not flag dynamic values within expect(...)' do
61
+ expect_no_violations(<<-'RUBY')
62
+ describe Foo do
63
+ it 'uses expect correctly' do
64
+ expect(foo).to eq(bar)
65
+ expect("foo#{baz}").to eq(bar)
66
+ expect(:"foo#{baz}").to eq(bar)
67
+ end
68
+ end
69
+ RUBY
70
+ end
71
+
72
+ it 'flags arrays containing only literal values within expect(...)' do
73
+ expect_violation(<<-RUBY)
74
+ describe Foo do
75
+ it 'uses expect incorrectly' do
76
+ expect([123]).to eq(bar)
77
+ ^^^^^ Provide the actual you are testing to `expect(...)`
78
+ expect([[123]]).to eq(bar)
79
+ ^^^^^^^ Provide the actual you are testing to `expect(...)`
80
+ end
81
+ end
82
+ RUBY
83
+ end
84
+
85
+ it 'flags hashes containing only literal values within expect(...)' do
86
+ expect_violation(<<-RUBY)
87
+ describe Foo do
88
+ it 'uses expect incorrectly' do
89
+ expect(foo: 1, bar: 2).to eq(bar)
90
+ ^^^^^^^^^^^^^^ Provide the actual you are testing to `expect(...)`
91
+ expect(foo: 1, bar: [{}]).to eq(bar)
92
+ ^^^^^^^^^^^^^^^^^ Provide the actual you are testing to `expect(...)`
93
+ end
94
+ end
95
+ RUBY
96
+ end
97
+
98
+ it 'flags ranges containing only literal values within expect(...)' do
99
+ expect_violation(<<-RUBY)
100
+ describe Foo do
101
+ it 'uses expect incorrectly' do
102
+ expect(1..2).to eq(bar)
103
+ ^^^^ Provide the actual you are testing to `expect(...)`
104
+ expect(1...2).to eq(bar)
105
+ ^^^^^ Provide the actual you are testing to `expect(...)`
106
+ end
107
+ end
108
+ RUBY
109
+ end
110
+
111
+ it 'flags regexps containing only literal values within expect(...)' do
112
+ expect_violation(<<-RUBY)
113
+ describe Foo do
114
+ it 'uses expect incorrectly' do
115
+ expect(/foo|bar/).to eq(bar)
116
+ ^^^^^^^^^ Provide the actual you are testing to `expect(...)`
117
+ end
118
+ end
119
+ RUBY
120
+ end
121
+
122
+ it 'does not flag complex values with dynamic parts within expect(...)' do
123
+ expect_no_violations(<<-'RUBY')
124
+ describe Foo do
125
+ it 'uses expect incorrectly' do
126
+ expect([foo]).to eq(bar)
127
+ expect([[foo]]).to eq(bar)
128
+ expect(foo: 1, bar: foo).to eq(bar)
129
+ expect(1..foo).to eq(bar)
130
+ expect(1...foo).to eq(bar)
131
+ expect(/foo|#{bar}/).to eq(bar)
132
+ end
133
+ end
134
+ RUBY
135
+ end
136
+ end
@@ -1,71 +1,60 @@
1
1
  describe RuboCop::Cop::RSpec::FilePath, :config do
2
2
  subject(:cop) { described_class.new(config) }
3
3
 
4
- it 'checks the path' do
5
- inspect_source(
6
- cop,
7
- "describe MyClass, 'foo' do; end",
8
- 'wrong_path_foo_spec.rb'
9
- )
10
- expect(cop.offenses.size).to eq(1)
11
- expect(cop.offenses.map(&:line).sort).to eq([1])
12
- expect(cop.messages)
13
- .to eq(['Spec path should end with `my_class*foo*_spec.rb`'])
4
+ shared_examples 'invalid spec path' do |source, expected:, actual:|
5
+ context "when `#{source}` is defined in #{actual}" do
6
+ before do
7
+ inspect_source(cop, source, actual)
8
+ end
9
+
10
+ it 'flags an offense' do
11
+ expect(cop.offenses.size).to eq(1)
12
+ end
13
+
14
+ it 'registers the offense on line 1' do
15
+ expect(cop.offenses.map(&:line)).to eq([1])
16
+ end
17
+
18
+ it 'adds a message saying what the path should end with' do
19
+ expect(cop.messages).to eql(["Spec path should end with `#{expected}`"])
20
+ end
21
+ end
14
22
  end
15
23
 
16
- it 'checks the path' do
17
- inspect_source(
18
- cop,
19
- "describe MyClass, '#foo' do; end",
20
- 'wrong_class_foo_spec.rb'
21
- )
22
- expect(cop.offenses.size).to eq(1)
23
- expect(cop.offenses.map(&:line).sort).to eq([1])
24
- expect(cop.messages)
25
- .to eq(['Spec path should end with `my_class*foo*_spec.rb`'])
26
- end
24
+ include_examples 'invalid spec path',
25
+ "describe MyClass, 'foo' do; end",
26
+ expected: 'my_class*foo*_spec.rb',
27
+ actual: 'wrong_path_foo_spec.rb'
27
28
 
28
- it 'flags foo_spec.rb.rb' do
29
- inspect_source(
30
- cop,
31
- "describe MyClass, '#foo' do; end",
32
- 'my_class/foo_spec.rb.rb'
33
- )
34
- expect(cop.offenses.size).to eq(1)
35
- end
29
+ include_examples 'invalid spec path',
30
+ "describe MyClass, '#foo' do; end",
31
+ expected: 'my_class*foo*_spec.rb',
32
+ actual: 'wrong_class_foo_spec.rb'
36
33
 
37
- it 'flags foo_specorb' do
38
- inspect_source(
39
- cop,
40
- "describe MyClass, '#foo' do; end",
41
- 'my_class/foo_specorb'
42
- )
43
- expect(cop.offenses.size).to eq(1)
44
- end
34
+ include_examples 'invalid spec path',
35
+ "describe MyClass, '#foo' do; end",
36
+ expected: 'my_class*foo*_spec.rb',
37
+ actual: 'my_class/foo_spec.rb.rb'
45
38
 
46
- it 'checks path even when metadata is included' do
47
- inspect_source(
48
- cop,
49
- "describe MyClass, '#foo', blah: :blah do; end",
50
- 'wrong_class_foo_spec.rb'
51
- )
52
- expect(cop.offenses.size).to eq(1)
53
- expect(cop.offenses.map(&:line).sort).to eq([1])
54
- expect(cop.messages)
55
- .to eq(['Spec path should end with `my_class*foo*_spec.rb`'])
56
- end
39
+ include_examples 'invalid spec path',
40
+ "describe MyClass, '#foo' do; end",
41
+ expected: 'my_class*foo*_spec.rb',
42
+ actual: 'my_class/foo_specorb'
57
43
 
58
- it 'checks class spec paths' do
59
- inspect_source(
60
- cop,
61
- 'describe MyClass do; end',
62
- 'wrong_class_spec.rb'
63
- )
64
- expect(cop.offenses.size).to eq(1)
65
- expect(cop.offenses.map(&:line).sort).to eq([1])
66
- expect(cop.messages)
67
- .to eq(['Spec path should end with `my_class*_spec.rb`'])
68
- end
44
+ include_examples 'invalid spec path',
45
+ "describe MyClass, '#foo', blah: :blah do; end",
46
+ expected: 'my_class*foo*_spec.rb',
47
+ actual: 'wrong_class_foo_spec.rb'
48
+
49
+ include_examples 'invalid spec path',
50
+ 'describe MyClass do; end',
51
+ expected: 'my_class*_spec.rb',
52
+ actual: 'wrong_class_spec.rb'
53
+
54
+ include_examples 'invalid spec path',
55
+ 'describe MyClass, :foo do; end',
56
+ expected: 'my_class*_spec.rb',
57
+ actual: 'wrong_class_spec.rb'
69
58
 
70
59
  it 'skips specs that do not describe a class / method' do
71
60
  inspect_source(
@@ -88,18 +77,6 @@ describe RuboCop::Cop::RSpec::FilePath, :config do
88
77
  expect(cop.offenses).to be_empty
89
78
  end
90
79
 
91
- it 'ignores second argument if is not a string' do
92
- inspect_source(
93
- cop,
94
- 'describe MyClass, :foo do; end',
95
- 'wrong_class_spec.rb'
96
- )
97
- expect(cop.offenses.size).to eq(1)
98
- expect(cop.offenses.map(&:line).sort).to eq([1])
99
- expect(cop.messages)
100
- .to eq(['Spec path should end with `my_class*_spec.rb`'])
101
- end
102
-
103
80
  it 'checks class specs' do
104
81
  inspect_source(
105
82
  cop,
@@ -37,7 +37,7 @@ describe RuboCop::Cop::RSpec::Focus do
37
37
  RUBY
38
38
  end
39
39
 
40
- it 'flags all repec example blocks that include `:focus`' do
40
+ it 'flags all rspec example blocks that include `:focus`' do
41
41
  expect_violation(<<-RUBY)
42
42
  example_group 'test', :focus do; end
43
43
  ^^^^^^ Focused spec found.
@@ -0,0 +1,189 @@
1
+ # encoding: utf-8
2
+
3
+ describe RuboCop::Cop::RSpec::HookArgument, :config do
4
+ subject(:cop) { described_class.new(config) }
5
+
6
+ let(:cop_config) do
7
+ { 'EnforcedStyle' => enforced_style }
8
+ end
9
+
10
+ let(:enforced_style) { :implicit }
11
+
12
+ shared_examples 'ignored hooks' do
13
+ it 'ignores :context and :suite' do
14
+ expect_no_violations(<<-RUBY)
15
+ before(:suite) { true }
16
+ after(:suite) { true }
17
+ before(:context) { true }
18
+ after(:context) { true }
19
+ RUBY
20
+ end
21
+
22
+ it 'ignores hooks with more than one argument' do
23
+ expect_no_violations(<<-RUBY)
24
+ before(:each, :something_custom) { true }
25
+ RUBY
26
+ end
27
+
28
+ it 'ignores non-rspec hooks' do
29
+ expect_no_violations(<<-RUBY)
30
+ setup(:each) { true }
31
+ RUBY
32
+ end
33
+ end
34
+
35
+ shared_examples 'generated config' do |source, detected_style|
36
+ it 'generates a todo based on the detected style' do
37
+ inspect_source(cop, source, 'foo_spec.rb')
38
+
39
+ expect(cop.config_to_allow_offenses)
40
+ .to eq('EnforcedStyle' => detected_style)
41
+ end
42
+ end
43
+
44
+ shared_examples 'hook autocorrect' do |output|
45
+ it 'autocorrects :each to EnforcedStyle' do
46
+ corrected =
47
+ autocorrect_source(cop, 'before(:each) { }', 'spec/foo_spec.rb')
48
+
49
+ expect(corrected).to eql(output)
50
+ end
51
+
52
+ it 'autocorrects :example to EnforcedStyle' do
53
+ corrected =
54
+ autocorrect_source(cop, 'before(:example) { }', 'spec/foo_spec.rb')
55
+
56
+ expect(corrected).to eql(output)
57
+ end
58
+
59
+ it 'autocorrects :implicit to EnforcedStyle' do
60
+ corrected =
61
+ autocorrect_source(cop, 'before { }', 'spec/foo_spec.rb')
62
+
63
+ expect(corrected).to eql(output)
64
+ end
65
+ end
66
+
67
+ shared_examples 'an example hook' do
68
+ include_examples 'ignored hooks'
69
+ include_examples 'generated config', 'before(:each) { foo }', 'each'
70
+ include_examples 'generated config', 'before(:example) { foo }', 'example'
71
+ include_examples 'generated config', 'before { foo }', 'implicit'
72
+ end
73
+
74
+ context 'when EnforcedStyle is :implicit' do
75
+ let(:enforced_style) { :implicit }
76
+
77
+ it 'detects :each for hooks' do
78
+ expect_violation(<<-RUBY)
79
+ before(:each) { true }
80
+ ^^^^^^^^^^^^^ Omit the default `:each` argument for RSpec hooks.
81
+ after(:each) { true }
82
+ ^^^^^^^^^^^^ Omit the default `:each` argument for RSpec hooks.
83
+ around(:each) { true }
84
+ ^^^^^^^^^^^^^ Omit the default `:each` argument for RSpec hooks.
85
+ RUBY
86
+ end
87
+
88
+ it 'detects :example for hooks' do
89
+ expect_violation(<<-RUBY)
90
+ before(:example) { true }
91
+ ^^^^^^^^^^^^^^^^ Omit the default `:example` argument for RSpec hooks.
92
+ after(:example) { true }
93
+ ^^^^^^^^^^^^^^^ Omit the default `:example` argument for RSpec hooks.
94
+ around(:example) { true }
95
+ ^^^^^^^^^^^^^^^^ Omit the default `:example` argument for RSpec hooks.
96
+ RUBY
97
+ end
98
+
99
+ it 'does not flag hooks without default scopes' do
100
+ expect_no_violations(<<-RUBY)
101
+ before { true }
102
+ after { true }
103
+ before { true }
104
+ after { true }
105
+ RUBY
106
+ end
107
+
108
+ include_examples 'an example hook'
109
+ include_examples 'hook autocorrect', 'before { }'
110
+ end
111
+
112
+ context 'when EnforcedStyle is :each' do
113
+ let(:enforced_style) { :each }
114
+
115
+ it 'detects :each for hooks' do
116
+ expect_no_violations(<<-RUBY)
117
+ before(:each) { true }
118
+ after(:each) { true }
119
+ around(:each) { true }
120
+ RUBY
121
+ end
122
+
123
+ it 'detects :example for hooks' do
124
+ expect_violation(<<-RUBY)
125
+ before(:example) { true }
126
+ ^^^^^^^^^^^^^^^^ Use `:each` for RSpec hooks.
127
+ after(:example) { true }
128
+ ^^^^^^^^^^^^^^^ Use `:each` for RSpec hooks.
129
+ around(:example) { true }
130
+ ^^^^^^^^^^^^^^^^ Use `:each` for RSpec hooks.
131
+ RUBY
132
+ end
133
+
134
+ it 'does not flag hooks without default scopes' do
135
+ expect_violation(<<-RUBY)
136
+ before { true }
137
+ ^^^^^^ Use `:each` for RSpec hooks.
138
+ after { true }
139
+ ^^^^^ Use `:each` for RSpec hooks.
140
+ before { true }
141
+ ^^^^^^ Use `:each` for RSpec hooks.
142
+ after { true }
143
+ ^^^^^ Use `:each` for RSpec hooks.
144
+ RUBY
145
+ end
146
+
147
+ include_examples 'an example hook'
148
+ include_examples 'hook autocorrect', 'before(:each) { }'
149
+ end
150
+
151
+ context 'when EnforcedStyle is :example' do
152
+ let(:enforced_style) { :example }
153
+
154
+ it 'detects :example for hooks' do
155
+ expect_no_violations(<<-RUBY)
156
+ before(:example) { true }
157
+ after(:example) { true }
158
+ around(:example) { true }
159
+ RUBY
160
+ end
161
+
162
+ it 'detects :each for hooks' do
163
+ expect_violation(<<-RUBY)
164
+ before(:each) { true }
165
+ ^^^^^^^^^^^^^ Use `:example` for RSpec hooks.
166
+ after(:each) { true }
167
+ ^^^^^^^^^^^^ Use `:example` for RSpec hooks.
168
+ around(:each) { true }
169
+ ^^^^^^^^^^^^^ Use `:example` for RSpec hooks.
170
+ RUBY
171
+ end
172
+
173
+ it 'does not flag hooks without default scopes' do
174
+ expect_violation(<<-RUBY)
175
+ before { true }
176
+ ^^^^^^ Use `:example` for RSpec hooks.
177
+ after { true }
178
+ ^^^^^ Use `:example` for RSpec hooks.
179
+ before { true }
180
+ ^^^^^^ Use `:example` for RSpec hooks.
181
+ after { true }
182
+ ^^^^^ Use `:example` for RSpec hooks.
183
+ RUBY
184
+ end
185
+
186
+ include_examples 'an example hook'
187
+ include_examples 'hook autocorrect', 'before(:example) { }'
188
+ end
189
+ end