|
84 | 84 | end
|
85 | 85 | end
|
86 | 86 |
|
| 87 | + context 'with instance_of assertions' do |
| 88 | + it 'registers an offense when using `assert_instance_of`' do |
| 89 | + expect_offense(<<~RUBY) |
| 90 | + assert_instance_of(a, b) |
| 91 | + ^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(b).to be_an_instance_of(a)`. |
| 92 | + RUBY |
| 93 | + |
| 94 | + expect_correction(<<~RUBY) |
| 95 | + expect(b).to be_an_instance_of(a) |
| 96 | + RUBY |
| 97 | + end |
| 98 | + |
| 99 | + it 'registers an offense when using `assert_instance_of` with ' \ |
| 100 | + 'no parentheses' do |
| 101 | + expect_offense(<<~RUBY) |
| 102 | + assert_instance_of a, b |
| 103 | + ^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(b).to be_an_instance_of(a)`. |
| 104 | + RUBY |
| 105 | + |
| 106 | + expect_correction(<<~RUBY) |
| 107 | + expect(b).to be_an_instance_of(a) |
| 108 | + RUBY |
| 109 | + end |
| 110 | + |
| 111 | + it 'registers an offense when using `assert_instance_of` with' \ |
| 112 | + 'failure message' do |
| 113 | + expect_offense(<<~RUBY) |
| 114 | + assert_instance_of a, b, "must be instance of" |
| 115 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(b).to(be_an_instance_of(a), "must be instance of")`. |
| 116 | + RUBY |
| 117 | + |
| 118 | + expect_correction(<<~RUBY) |
| 119 | + expect(b).to(be_an_instance_of(a), "must be instance of") |
| 120 | + RUBY |
| 121 | + end |
| 122 | + |
| 123 | + it 'registers an offense when using `assert_instance_of` with ' \ |
| 124 | + 'multi-line arguments' do |
| 125 | + expect_offense(<<~RUBY) |
| 126 | + assert_instance_of(a, |
| 127 | + ^^^^^^^^^^^^^^^^^^^^^ Use `expect(b).to(be_an_instance_of(a), "must be instance of")`. |
| 128 | + b, |
| 129 | + "must be instance of") |
| 130 | + RUBY |
| 131 | + |
| 132 | + expect_correction(<<~RUBY) |
| 133 | + expect(b).to(be_an_instance_of(a), "must be instance of") |
| 134 | + RUBY |
| 135 | + end |
| 136 | + |
| 137 | + it 'registers an offense when using `assert_not_instance_of`' do |
| 138 | + expect_offense(<<~RUBY) |
| 139 | + assert_not_instance_of a, b |
| 140 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(b).not_to be_an_instance_of(a)`. |
| 141 | + RUBY |
| 142 | + |
| 143 | + expect_correction(<<~RUBY) |
| 144 | + expect(b).not_to be_an_instance_of(a) |
| 145 | + RUBY |
| 146 | + end |
| 147 | + |
| 148 | + it 'registers an offense when using `refute_instance_of`' do |
| 149 | + expect_offense(<<~RUBY) |
| 150 | + refute_instance_of a, b |
| 151 | + ^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(b).not_to be_an_instance_of(a)`. |
| 152 | + RUBY |
| 153 | + |
| 154 | + expect_correction(<<~RUBY) |
| 155 | + expect(b).not_to be_an_instance_of(a) |
| 156 | + RUBY |
| 157 | + end |
| 158 | + |
| 159 | + it 'does not register an offense when ' \ |
| 160 | + 'using `expect(b).to be_an_instance_of(a)`' do |
| 161 | + expect_no_offenses(<<~RUBY) |
| 162 | + expect(b).to be_an_instance_of(a) |
| 163 | + RUBY |
| 164 | + end |
| 165 | + |
| 166 | + it 'does not register an offense when ' \ |
| 167 | + 'using `expect(b).not_to be_an_instance_of(a)`' do |
| 168 | + expect_no_offenses(<<~RUBY) |
| 169 | + expect(b).not_to be_an_instance_of(a) |
| 170 | + RUBY |
| 171 | + end |
| 172 | + |
| 173 | + it 'does not register an offense when ' \ |
| 174 | + 'using `expect(b).to be_instance_of(a)`' do |
| 175 | + expect_no_offenses(<<~RUBY) |
| 176 | + expect(b).to be_instance_of(a) |
| 177 | + RUBY |
| 178 | + end |
| 179 | + |
| 180 | + it 'does not register an offense when ' \ |
| 181 | + 'using `expect(b).not_to be_instance_of(a)`' do |
| 182 | + expect_no_offenses(<<~RUBY) |
| 183 | + expect(b).not_to be_instance_of(a) |
| 184 | + RUBY |
| 185 | + end |
| 186 | + end |
| 187 | + |
87 | 188 | context 'with includes assertions' do
|
88 | 189 | it 'registers an offense when using `assert_includes`' do
|
89 | 190 | expect_offense(<<~RUBY)
|
|
150 | 251 | refute_includes a, b
|
151 | 252 | ^^^^^^^^^^^^^^^^^^^^ Use `expect(a).not_to include(b)`.
|
152 | 253 | RUBY
|
153 |
| - |
154 |
| - expect_correction(<<~RUBY) |
155 |
| - expect(a).not_to include(b) |
156 |
| - RUBY |
157 |
| - end |
158 |
| - |
159 |
| - it 'does not register an offense when using `expect(a).to include(b)`' do |
160 |
| - expect_no_offenses(<<~RUBY) |
161 |
| - expect(a).to include(b) |
162 |
| - RUBY |
163 |
| - end |
164 |
| - |
165 |
| - it 'does not register an offense when ' \ |
166 |
| - 'using `expect(a).not_to include(b)`' do |
167 |
| - expect_no_offenses(<<~RUBY) |
168 |
| - expect(a).not_to include(b) |
169 |
| - RUBY |
170 | 254 | end
|
171 | 255 | end
|
172 | 256 |
|
|
0 commit comments