|
11 | 11 | it 'registers an offense for an exit! call with no receiver' do |
12 | 12 | expect_offense(<<~RUBY) |
13 | 13 | exit! |
14 | | - ^^^^^ Do not use `exit` in Rails applications. |
| 14 | + ^^^^^ Do not use `exit!` in Rails applications. |
| 15 | + RUBY |
| 16 | + end |
| 17 | + |
| 18 | + it 'registers an offense for an abort call with no receiver' do |
| 19 | + expect_offense(<<~RUBY) |
| 20 | + abort |
| 21 | + ^^^^^ Do not use `abort` in Rails applications. |
15 | 22 | RUBY |
16 | 23 | end |
17 | 24 |
|
|
27 | 34 | it 'does not register an offense for an explicit exit! call on an object' do |
28 | 35 | expect_no_offenses('Object.new.exit!(0)') |
29 | 36 | end |
| 37 | + |
| 38 | + it 'does not register an offense for an explicit abort call on an object' do |
| 39 | + expect_no_offenses('Object.new.abort("failed")') |
| 40 | + end |
30 | 41 | end |
31 | 42 |
|
32 | 43 | context 'with arguments' do |
|
40 | 51 | it 'ignores exit calls with unexpected number of parameters' do |
41 | 52 | expect_no_offenses('exit(1, 2)') |
42 | 53 | end |
| 54 | + |
| 55 | + it 'registers an offense for an abort("message") call with no receiver' do |
| 56 | + expect_offense(<<~RUBY) |
| 57 | + abort("message") |
| 58 | + ^^^^^ Do not use `abort` in Rails applications. |
| 59 | + RUBY |
| 60 | + end |
| 61 | + |
| 62 | + it 'ignores abort calls with unexpected number of parameters' do |
| 63 | + expect_no_offenses('abort("message", "another message")') |
| 64 | + end |
43 | 65 | end |
44 | 66 |
|
45 | 67 | context 'explicit calls' do |
|
56 | 78 | ^^^^ Do not use `exit` in Rails applications. |
57 | 79 | RUBY |
58 | 80 | end |
| 81 | + |
| 82 | + it 'does register an offense for explicit Kernel.abort calls' do |
| 83 | + expect_offense(<<~RUBY) |
| 84 | + Kernel.abort |
| 85 | + ^^^^^ Do not use `abort` in Rails applications. |
| 86 | + RUBY |
| 87 | + end |
| 88 | + |
| 89 | + it 'does register an offense for explicit Process.abort calls' do |
| 90 | + expect_offense(<<~RUBY) |
| 91 | + Process.abort |
| 92 | + ^^^^^ Do not use `abort` in Rails applications. |
| 93 | + RUBY |
| 94 | + end |
59 | 95 | end |
60 | 96 | end |
0 commit comments