|
95 | 95 |
|
96 | 96 | it 'registers an offense for a predicate method with heredoc' do
|
97 | 97 | expect_offense(<<~RUBY)
|
98 |
| - expect(foo.include?(<<~TEXT)).to be_truthy |
99 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `include` matcher over `include?`. |
| 98 | + expect(foo.something?(<<~TEXT)).to be_truthy |
| 99 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_something` matcher over `something?`. |
100 | 100 | bar
|
101 | 101 | TEXT
|
102 | 102 | RUBY
|
103 | 103 |
|
104 | 104 | expect_correction(<<~RUBY)
|
105 |
| - expect(foo).to include(<<~TEXT) |
| 105 | + expect(foo).to be_something(<<~TEXT) |
106 | 106 | bar
|
107 | 107 | TEXT
|
108 | 108 | RUBY
|
|
346 | 346 | 'heredoc and multiline expect' do
|
347 | 347 | expect_offense(<<~RUBY)
|
348 | 348 | expect(foo)
|
349 |
| - ^^^^^^^^^^^ Prefer using `include?` over `include` matcher. |
350 |
| - .to include(<<~TEXT) |
| 349 | + ^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher. |
| 350 | + .to be_something(<<~TEXT) |
351 | 351 | bar
|
352 | 352 | TEXT
|
353 | 353 |
|
354 | 354 | expect(foo)
|
355 |
| - ^^^^^^^^^^^ Prefer using `include?` over `include` matcher. |
356 |
| - .to include(bar, <<~TEXT, 'baz') |
| 355 | + ^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher. |
| 356 | + .to be_something(bar, <<~TEXT, 'baz') |
357 | 357 | bar
|
358 | 358 | TEXT
|
359 | 359 | RUBY
|
|
365 | 365 | 'heredoc include #{} and multiline expect' do
|
366 | 366 | expect_offense(<<~'RUBY')
|
367 | 367 | expect(foo)
|
368 |
| - ^^^^^^^^^^^ Prefer using `include?` over `include` matcher. |
369 |
| - .to include(<<~TEXT) |
| 368 | + ^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher. |
| 369 | + .to be_something(<<~TEXT) |
370 | 370 | #{bar}
|
371 | 371 | TEXT
|
372 | 372 |
|
373 | 373 | expect(foo)
|
374 |
| - ^^^^^^^^^^^ Prefer using `include?` over `include` matcher. |
375 |
| - .to include(bar, <<~TEXT, 'baz') |
| 374 | + ^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher. |
| 375 | + .to be_something(bar, <<~TEXT, 'baz') |
376 | 376 | #{bar}
|
377 | 377 | TEXT
|
378 | 378 | RUBY
|
|
384 | 384 | 'heredoc surrounded by back ticks and multiline expect' do
|
385 | 385 | expect_offense(<<~'RUBY')
|
386 | 386 | expect(foo)
|
387 |
| - ^^^^^^^^^^^ Prefer using `include?` over `include` matcher. |
388 |
| - .to include(<<~`COMMAND`) |
| 387 | + ^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher. |
| 388 | + .to be_something(<<~`COMMAND`) |
389 | 389 | pwd
|
390 | 390 | COMMAND
|
391 | 391 |
|
392 | 392 | expect(foo)
|
393 |
| - ^^^^^^^^^^^ Prefer using `include?` over `include` matcher. |
394 |
| - .to include(bar, <<~COMMAND, 'baz') |
| 393 | + ^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher. |
| 394 | + .to be_something(bar, <<~COMMAND, 'baz') |
395 | 395 | pwd
|
396 | 396 | COMMAND
|
397 | 397 | RUBY
|
398 | 398 |
|
399 | 399 | expect_no_corrections
|
400 | 400 | end
|
401 | 401 |
|
| 402 | + it 'does not register an offense for a `include` ' \ |
| 403 | + 'with no argument' do |
| 404 | + expect_no_offenses(<<~RUBY) |
| 405 | + expect(foo).to include |
| 406 | + RUBY |
| 407 | + end |
| 408 | + |
| 409 | + it 'does not register an offense for a `include` ' \ |
| 410 | + 'with multiple arguments' do |
| 411 | + expect_no_offenses(<<~RUBY) |
| 412 | + expect(foo).to include(foo, bar) |
| 413 | + RUBY |
| 414 | + end |
| 415 | + |
402 | 416 | it 'registers an offense for a predicate method with a block' do
|
403 | 417 | expect_offense(<<~RUBY)
|
404 | 418 | expect(foo).to be_all { |x| x.present? }
|
|
0 commit comments