|
4 | 4 | it 'registers an offense for an exit call with no receiver' do
|
5 | 5 | expect_offense(<<~RUBY)
|
6 | 6 | exit
|
7 |
| - ^^^^ Do not use `exit` in Rails applications. |
| 7 | + ^^^^ Do not use `exit` or `abort` in Rails applications. |
8 | 8 | RUBY
|
9 | 9 | end
|
10 | 10 |
|
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` or `abort` 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 `exit` or `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
|
33 | 44 | it 'registers an offense for an exit(0) call with no receiver' do
|
34 | 45 | expect_offense(<<~RUBY)
|
35 | 46 | exit(0)
|
36 |
| - ^^^^ Do not use `exit` in Rails applications. |
| 47 | + ^^^^ Do not use `exit` or `abort` in Rails applications. |
37 | 48 | RUBY
|
38 | 49 | end
|
39 | 50 |
|
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 `exit` or `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
|
46 | 68 | it 'does register an offense for explicit Kernel.exit calls' do
|
47 | 69 | expect_offense(<<~RUBY)
|
48 | 70 | Kernel.exit
|
49 |
| - ^^^^ Do not use `exit` in Rails applications. |
| 71 | + ^^^^ Do not use `exit` or `abort` in Rails applications. |
50 | 72 | RUBY
|
51 | 73 | end
|
52 | 74 |
|
53 | 75 | it 'does register an offense for explicit Process.exit calls' do
|
54 | 76 | expect_offense(<<~RUBY)
|
55 | 77 | Process.exit
|
56 |
| - ^^^^ Do not use `exit` in Rails applications. |
| 78 | + ^^^^ Do not use `exit` or `abort` in Rails applications. |
| 79 | + RUBY |
| 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 `exit` or `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 `exit` or `abort` in Rails applications. |
57 | 93 | RUBY
|
58 | 94 | end
|
59 | 95 | end
|
|
0 commit comments