|
28 | 28 | end
|
29 | 29 | end
|
30 | 30 |
|
31 |
| - shared_examples 'hook autocorrect' do |output| |
32 |
| - include_examples 'autocorrect', 'before(:each) { }', output |
33 |
| - include_examples 'autocorrect', 'before(:example) { }', output |
34 |
| - include_examples 'autocorrect', 'before { }', output |
35 |
| - |
36 |
| - include_examples 'autocorrect', 'config.before(:each) { }', |
37 |
| - "config.#{output}" |
38 |
| - include_examples 'autocorrect', 'config.before(:example) { }', |
39 |
| - "config.#{output}" |
40 |
| - include_examples 'autocorrect', 'config.before { }', |
41 |
| - "config.#{output}" |
42 |
| - end |
43 |
| - |
44 | 31 | shared_examples 'an example hook' do
|
45 | 32 | include_examples 'ignored hooks'
|
46 | 33 | include_examples 'detects style', 'before(:each) { foo }', 'each'
|
|
62 | 49 | config.after(:each) { true }
|
63 | 50 | ^^^^^^^^^^^^^^^^^^^ Omit the default `:each` argument for RSpec hooks.
|
64 | 51 | RUBY
|
| 52 | + |
| 53 | + expect_correction(<<-RUBY) |
| 54 | + before { true } |
| 55 | + after { true } |
| 56 | + around { true } |
| 57 | + config.after { true } |
| 58 | + RUBY |
65 | 59 | end
|
66 | 60 |
|
67 | 61 | it 'detects :example for hooks' do
|
|
75 | 69 | config.before(:example) { true }
|
76 | 70 | ^^^^^^^^^^^^^^^^^^^^^^^ Omit the default `:example` argument for RSpec hooks.
|
77 | 71 | RUBY
|
| 72 | + |
| 73 | + expect_correction(<<-RUBY) |
| 74 | + before { true } |
| 75 | + after { true } |
| 76 | + around { true } |
| 77 | + config.before { true } |
| 78 | + RUBY |
78 | 79 | end
|
79 | 80 |
|
80 | 81 | it 'does not flag hooks without default scopes' do
|
|
87 | 88 | end
|
88 | 89 |
|
89 | 90 | include_examples 'an example hook'
|
90 |
| - include_examples 'hook autocorrect', 'before { }' |
91 | 91 | end
|
92 | 92 |
|
93 | 93 | context 'when EnforcedStyle is :each' do
|
|
113 | 113 | config.before(:example) { true }
|
114 | 114 | ^^^^^^^^^^^^^^^^^^^^^^^ Use `:each` for RSpec hooks.
|
115 | 115 | RUBY
|
| 116 | + |
| 117 | + expect_correction(<<-RUBY) |
| 118 | + before(:each) { true } |
| 119 | + after(:each) { true } |
| 120 | + around(:each) { true } |
| 121 | + config.before(:each) { true } |
| 122 | + RUBY |
116 | 123 | end
|
117 | 124 |
|
118 | 125 | it 'detects hooks without default scopes' do
|
|
126 | 133 | config.before { true }
|
127 | 134 | ^^^^^^ Use `:each` for RSpec hooks.
|
128 | 135 | RUBY
|
| 136 | + |
| 137 | + expect_correction(<<-RUBY) |
| 138 | + before(:each) { true } |
| 139 | + after(:each) { true } |
| 140 | + around(:each) { true } |
| 141 | + config.before(:each) { true } |
| 142 | + RUBY |
129 | 143 | end
|
130 | 144 |
|
131 | 145 | include_examples 'an example hook'
|
132 |
| - include_examples 'hook autocorrect', 'before(:each) { }' |
133 | 146 | end
|
134 | 147 |
|
135 | 148 | context 'when EnforcedStyle is :example' do
|
|
155 | 168 | config.before(:each) { true }
|
156 | 169 | ^^^^^^^^^^^^^^^^^^^^ Use `:example` for RSpec hooks.
|
157 | 170 | RUBY
|
| 171 | + |
| 172 | + expect_correction(<<-RUBY) |
| 173 | + before(:example) { true } |
| 174 | + after(:example) { true } |
| 175 | + around(:example) { true } |
| 176 | + config.before(:example) { true } |
| 177 | + RUBY |
158 | 178 | end
|
159 | 179 |
|
160 | 180 | it 'detects hooks without default scopes' do
|
|
168 | 188 | config.before { true }
|
169 | 189 | ^^^^^^ Use `:example` for RSpec hooks.
|
170 | 190 | RUBY
|
| 191 | + |
| 192 | + expect_correction(<<-RUBY) |
| 193 | + before(:example) { true } |
| 194 | + after(:example) { true } |
| 195 | + around(:example) { true } |
| 196 | + config.before(:example) { true } |
| 197 | + RUBY |
171 | 198 | end
|
172 | 199 |
|
173 | 200 | include_examples 'an example hook'
|
174 |
| - include_examples 'hook autocorrect', 'before(:example) { }' |
175 | 201 | end
|
176 | 202 | end
|
0 commit comments