|
4 | 4 | it 'registers an offense for repeated describe descriptions' do
|
5 | 5 | expect_offense(<<~RUBY)
|
6 | 6 | describe 'doing x' do
|
7 |
| - ^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [5] |
| 7 | + ^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 5. |
8 | 8 | # example group
|
9 | 9 | end
|
10 | 10 |
|
11 | 11 | describe 'doing x' do
|
12 |
| - ^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [1] |
| 12 | + ^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 1. |
13 | 13 | # example group
|
14 | 14 | end
|
15 | 15 | RUBY
|
|
18 | 18 | it 'registers an offense for repeated context descriptions' do
|
19 | 19 | expect_offense(<<~RUBY)
|
20 | 20 | context 'when awesome case' do
|
21 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [5] |
| 21 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 5. |
22 | 22 | # example group
|
23 | 23 | end
|
24 | 24 |
|
25 | 25 | context 'when awesome case' do
|
26 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [1] |
| 26 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 1. |
27 | 27 | # example group
|
28 | 28 | end
|
29 | 29 | RUBY
|
|
37 | 37 | end
|
38 | 38 |
|
39 | 39 | context 'when awesome case' do
|
40 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [10, 14] |
| 40 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 10, 14. |
41 | 41 | # example group
|
42 | 42 | end
|
43 | 43 |
|
44 | 44 | context 'when awesome case' do
|
45 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [6, 14] |
| 45 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 6, 14. |
46 | 46 | # example group
|
47 | 47 | end
|
48 | 48 |
|
49 | 49 | context 'when awesome case' do
|
50 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [6, 10] |
| 50 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 6, 10. |
51 | 51 | # example group
|
52 | 52 | end
|
53 | 53 | end
|
|
94 | 94 | 'similar descriptions' do
|
95 | 95 | expect_offense(<<~RUBY)
|
96 | 96 | describe 'Animal' do
|
97 |
| - ^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [5] |
| 97 | + ^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 5. |
98 | 98 | # example group
|
99 | 99 | end
|
100 | 100 |
|
101 | 101 | context 'Animal' do
|
102 |
| - ^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [1] |
| 102 | + ^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 1. |
103 | 103 | # example group
|
104 | 104 | end
|
105 | 105 | RUBY
|
|
112 | 112 | end
|
113 | 113 |
|
114 | 114 | RSpec.describe 'doing x' do
|
115 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [9] |
| 115 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 9. |
116 | 116 | it { cool_predicate_method }
|
117 | 117 | end
|
118 | 118 |
|
119 | 119 | context 'doing x' do
|
120 |
| - ^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [5] |
| 120 | + ^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 5. |
121 | 121 | it { cool_predicate_method }
|
122 | 122 | end
|
123 | 123 | RUBY
|
|
126 | 126 | it 'registers offense only for RSPEC namespace example groups in any order' do
|
127 | 127 | expect_offense(<<~RUBY)
|
128 | 128 | RSpec.describe 'doing x' do
|
129 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [5] |
| 129 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 5. |
130 | 130 | it { cool_predicate_method }
|
131 | 131 | end
|
132 | 132 |
|
133 | 133 | context 'doing x' do
|
134 |
| - ^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [1] |
| 134 | + ^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 1. |
135 | 135 | it { cool_predicate_method }
|
136 | 136 | end
|
137 | 137 |
|
|
149 | 149 | before { create(:admin) }
|
150 | 150 |
|
151 | 151 | describe '#load' do
|
152 |
| - ^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [10] |
| 152 | + ^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 10. |
153 | 153 | it { cool_predicate_method }
|
154 | 154 | end
|
155 | 155 |
|
156 | 156 | describe '#load' do
|
157 |
| - ^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [6] |
| 157 | + ^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 6. |
158 | 158 | it { cool_predicate_method }
|
159 | 159 | end
|
160 | 160 | end
|
|
176 | 176 | it 'registers offense correctly for interpolated docstrings' do
|
177 | 177 | expect_offense(<<~RUBY)
|
178 | 178 | context "when class is \#{A::B}" do
|
179 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [5] |
| 179 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 5. |
180 | 180 | # ...
|
181 | 181 | end
|
182 | 182 |
|
183 | 183 | context "when class is \#{A::B}" do
|
184 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [1] |
| 184 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 1. |
185 | 185 | # ...
|
186 | 186 | end
|
187 | 187 | RUBY
|
|
202 | 202 | it 'registers offense if same method used in docstring' do
|
203 | 203 | expect_offense(<<~RUBY)
|
204 | 204 | context(description) do
|
205 |
| - ^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [5] |
| 205 | + ^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 5. |
206 | 206 | # ...
|
207 | 207 | end
|
208 | 208 |
|
209 | 209 | context(description) do
|
210 |
| - ^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) [1] |
| 210 | + ^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 1. |
211 | 211 | # ...
|
212 | 212 | end
|
213 | 213 | RUBY
|
|
216 | 216 | it 'registers offense correctly if example groups are separated' do
|
217 | 217 | expect_offense(<<~RUBY)
|
218 | 218 | describe 'repeated' do
|
219 |
| - ^^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [7] |
| 219 | + ^^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 7. |
220 | 220 | it { is_expected.to be_truthy }
|
221 | 221 | end
|
222 | 222 |
|
223 | 223 | before { do_something }
|
224 | 224 |
|
225 | 225 | describe 'repeated' do
|
226 |
| - ^^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) [1] |
| 226 | + ^^^^^^^^^^^^^^^^^^^^^^ Repeated describe block description on line(s) 1. |
227 | 227 | it { is_expected.to be_truthy }
|
228 | 228 | end
|
229 | 229 | RUBY
|
|
240 | 240 | end
|
241 | 241 | RUBY
|
242 | 242 | end
|
| 243 | + |
| 244 | + # New tests for pending/skip detection |
| 245 | + |
| 246 | + it 'registers offense for repeated descriptions with pending examples' do |
| 247 | + expect_offense(<<~RUBY) |
| 248 | + describe 'Screenshots::CreateInteractor' do |
| 249 | + context 'when the request is valid' do |
| 250 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 6. |
| 251 | + pending 'add something' |
| 252 | + end |
| 253 | +
|
| 254 | + context 'when the request is valid' do |
| 255 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 2. |
| 256 | + pending 'add something' |
| 257 | + end |
| 258 | + end |
| 259 | + RUBY |
| 260 | + end |
| 261 | + |
| 262 | + it 'registers offense for repeated descriptions with skip examples' do |
| 263 | + expect_offense(<<~RUBY) |
| 264 | + describe 'Something' do |
| 265 | + context 'when foo' do |
| 266 | + ^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 6. |
| 267 | + skip 'not implemented' |
| 268 | + end |
| 269 | +
|
| 270 | + context 'when foo' do |
| 271 | + ^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 2. |
| 272 | + skip 'not implemented' |
| 273 | + end |
| 274 | + end |
| 275 | + RUBY |
| 276 | + end |
| 277 | + |
| 278 | + it 'registers offense for repeated descriptions with pending metadata' do |
| 279 | + expect_offense(<<~RUBY) |
| 280 | + describe 'Something' do |
| 281 | + context 'when foo', :pending do |
| 282 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 5. |
| 283 | + end |
| 284 | +
|
| 285 | + context 'when foo', :pending do |
| 286 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 2. |
| 287 | + end |
| 288 | + end |
| 289 | + RUBY |
| 290 | + end |
| 291 | + |
| 292 | + it 'registers offense for repeated descriptions with skip metadata' do |
| 293 | + expect_offense(<<~RUBY) |
| 294 | + describe 'Something' do |
| 295 | + context 'when foo', :skip do |
| 296 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 5. |
| 297 | + end |
| 298 | +
|
| 299 | + context 'when foo', :skip do |
| 300 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 2. |
| 301 | + end |
| 302 | + end |
| 303 | + RUBY |
| 304 | + end |
| 305 | + |
| 306 | + it 'registers offense for repeated descriptions with skip metadata hash' do |
| 307 | + expect_offense(<<~RUBY) |
| 308 | + describe 'Something' do |
| 309 | + context 'when foo', skip: true do |
| 310 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 5. |
| 311 | + end |
| 312 | +
|
| 313 | + context 'when foo', skip: true do |
| 314 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 2. |
| 315 | + end |
| 316 | + end |
| 317 | + RUBY |
| 318 | + end |
| 319 | + |
| 320 | + it 'registers offense for repeated descriptions with pending metadata hash' do |
| 321 | + expect_offense(<<~RUBY) |
| 322 | + describe 'Something' do |
| 323 | + context 'when foo', pending: 'not ready' do |
| 324 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 5. |
| 325 | + end |
| 326 | +
|
| 327 | + context 'when foo', pending: 'not ready' do |
| 328 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 2. |
| 329 | + end |
| 330 | + end |
| 331 | + RUBY |
| 332 | + end |
| 333 | + |
| 334 | + it 'registers offense with mixed pending and skip' do |
| 335 | + expect_offense(<<~RUBY) |
| 336 | + describe 'Something' do |
| 337 | + context 'when foo' do |
| 338 | + ^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 6. |
| 339 | + pending 'add something' |
| 340 | + end |
| 341 | +
|
| 342 | + context 'when foo' do |
| 343 | + ^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 2. |
| 344 | + skip 'not ready' |
| 345 | + end |
| 346 | + end |
| 347 | + RUBY |
| 348 | + end |
| 349 | + |
| 350 | + it 'registers offense for repeated descriptions with xcontext' do |
| 351 | + expect_offense(<<~RUBY) |
| 352 | + describe 'Something' do |
| 353 | + xcontext 'when foo' do |
| 354 | + ^^^^^^^^^^^^^^^^^^^^^^ Repeated xcontext block description on line(s) 5. |
| 355 | + end |
| 356 | +
|
| 357 | + xcontext 'when foo' do |
| 358 | + ^^^^^^^^^^^^^^^^^^^^^^ Repeated xcontext block description on line(s) 2. |
| 359 | + end |
| 360 | + end |
| 361 | + RUBY |
| 362 | + end |
| 363 | + |
| 364 | + it 'registers offense for repeated descriptions with xdescribe' do |
| 365 | + expect_offense(<<~RUBY) |
| 366 | + xdescribe 'Something' do |
| 367 | + ^^^^^^^^^^^^^^^^^^^^^^^^ Repeated xdescribe block description on line(s) 5. |
| 368 | + it { is_expected.to be_valid } |
| 369 | + end |
| 370 | +
|
| 371 | + xdescribe 'Something' do |
| 372 | + ^^^^^^^^^^^^^^^^^^^^^^^^ Repeated xdescribe block description on line(s) 1. |
| 373 | + it { is_expected.to be_valid } |
| 374 | + end |
| 375 | + RUBY |
| 376 | + end |
| 377 | + |
| 378 | + it 'registers offense when one group has pending and other does not' do |
| 379 | + expect_offense(<<~RUBY) |
| 380 | + describe 'Something' do |
| 381 | + context 'when foo' do |
| 382 | + ^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 6. |
| 383 | + pending 'add something' |
| 384 | + end |
| 385 | +
|
| 386 | + context 'when foo' do |
| 387 | + ^^^^^^^^^^^^^^^^^^^^^ Repeated context block description on line(s) 2. |
| 388 | + it { is_expected.to be_valid } |
| 389 | + end |
| 390 | + end |
| 391 | + RUBY |
| 392 | + end |
243 | 393 | end
|
0 commit comments