|
16 | 16 | expect_offense(<<~RUBY)
|
17 | 17 | expect(foo.empty?).to be_truthy
|
18 | 18 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`.
|
| 19 | + expect(foo.empty?).to be_truthy, 'fail' |
| 20 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`. |
19 | 21 | expect(foo.empty?).not_to be_truthy
|
20 | 22 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`.
|
21 | 23 | expect(foo.empty?).to_not be_truthy
|
|
30 | 32 |
|
31 | 33 | expect_correction(<<~RUBY)
|
32 | 34 | expect(foo).to be_empty
|
| 35 | + expect(foo).to be_empty, 'fail' |
33 | 36 | expect(foo).not_to be_empty
|
34 | 37 | expect(foo).not_to be_empty
|
35 | 38 | expect(foo).not_to be_empty
|
|
42 | 45 | expect_offense(<<~RUBY)
|
43 | 46 | expect(foo.exist?).to be_truthy
|
44 | 47 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `exist` matcher over `exist?`.
|
| 48 | + expect(foo.exist?).to be_truthy, 'fail' |
| 49 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `exist` matcher over `exist?`. |
45 | 50 | expect(foo.exists?).to be_truthy
|
46 | 51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `exist` matcher over `exists?`.
|
47 | 52 | expect(foo.has_something?).to be_truthy
|
|
58 | 63 |
|
59 | 64 | expect_correction(<<~RUBY)
|
60 | 65 | expect(foo).to exist
|
| 66 | + expect(foo).to exist, 'fail' |
61 | 67 | expect(foo).to exist
|
62 | 68 | expect(foo).to have_something
|
63 | 69 | expect(foo).not_to have_something
|
|
71 | 77 | expect_offense(<<~RUBY)
|
72 | 78 | expect(foo.something?('foo')).to be_truthy
|
73 | 79 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_something` matcher over `something?`.
|
| 80 | + expect(foo.something?('foo')).to be_truthy, 'fail' |
| 81 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_something` matcher over `something?`. |
74 | 82 | expect(foo.something?('foo', 'bar')).to be_truthy
|
75 | 83 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_something` matcher over `something?`.
|
76 | 84 | expect(foo.something? 1, 2).to be_truthy
|
|
85 | 93 |
|
86 | 94 | expect_correction(<<~RUBY)
|
87 | 95 | expect(foo).to be_something('foo')
|
| 96 | + expect(foo).to be_something('foo'), 'fail' |
88 | 97 | expect(foo).to be_something('foo', 'bar')
|
89 | 98 | expect(foo).to be_something 1, 2
|
90 | 99 | expect(foo).to have_key('foo')
|
|
112 | 121 | expect_offense(<<~RUBY)
|
113 | 122 | expect(foo.all?(&:present?)).to be_truthy
|
114 | 123 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_all` matcher over `all?`.
|
| 124 | + expect(foo.all?(&:present?)).to be_truthy, 'fail' |
| 125 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_all` matcher over `all?`. |
115 | 126 | expect(foo.all? { |x| x.present? }).to be_truthy
|
116 | 127 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_all` matcher over `all?`.
|
117 | 128 | expect(foo.all?(n) { |x| x.present? }).to be_truthy
|
|
134 | 145 |
|
135 | 146 | expect_correction(<<~RUBY)
|
136 | 147 | expect(foo).to be_all(&:present?)
|
| 148 | + expect(foo).to be_all(&:present?), 'fail' |
137 | 149 | expect(foo).to be_all { |x| x.present? }
|
138 | 150 | expect(foo).to be_all(n) { |x| x.present? }
|
139 | 151 | expect(foo).to be_all { present }
|
|
151 | 163 | it 'accepts a predicate method that is not checked true/false' do
|
152 | 164 | expect_no_offenses(<<~RUBY)
|
153 | 165 | expect(foo.something?).to eq "something"
|
| 166 | + expect(foo.something?).to eq "something", "fail" |
154 | 167 | expect(foo.has_something?).to eq "something"
|
155 | 168 | RUBY
|
156 | 169 | end
|
157 | 170 |
|
158 | 171 | it 'accepts non-predicate method' do
|
159 | 172 | expect_no_offenses(<<~RUBY)
|
160 | 173 | expect(foo.something).to be(true)
|
| 174 | + expect(foo.something).to be(true), 'fail' |
161 | 175 | expect(foo.has_something).to be(true)
|
162 | 176 | RUBY
|
163 | 177 | end
|
|
171 | 185 | it 'accepts strict checking boolean matcher' do
|
172 | 186 | expect_no_offenses(<<~RUBY)
|
173 | 187 | expect(foo.empty?).to eq(true)
|
| 188 | + expect(foo.empty?).to eq(true), 'fail' |
174 | 189 | expect(foo.empty?).to be(true)
|
175 | 190 | expect(foo.empty?).to be(false)
|
176 | 191 | expect(foo.empty?).not_to be true
|
|
188 | 203 | expect_offense(<<~RUBY)
|
189 | 204 | expect(foo.empty?).to eq(true)
|
190 | 205 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`.
|
| 206 | + expect(foo.empty?).to eq(true), 'fail' |
| 207 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`. |
191 | 208 | expect(foo.empty?).not_to be(true)
|
192 | 209 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`.
|
193 | 210 | expect(foo.empty?).to be(true)
|
|
202 | 219 |
|
203 | 220 | expect_correction(<<~RUBY)
|
204 | 221 | expect(foo).to be_empty
|
| 222 | + expect(foo).to be_empty, 'fail' |
205 | 223 | expect(foo).not_to be_empty
|
206 | 224 | expect(foo).to be_empty
|
207 | 225 | expect(foo).not_to be_empty
|
|
220 | 238 | expect_offense(<<~RUBY)
|
221 | 239 | expect(foo).to be_empty
|
222 | 240 | ^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `empty?` over `be_empty` matcher.
|
| 241 | + expect(foo).to be_empty, 'fail' |
| 242 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `empty?` over `be_empty` matcher. |
223 | 243 | expect(foo).not_to be_empty
|
224 | 244 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `empty?` over `be_empty` matcher.
|
225 | 245 | expect(foo).to have_something
|
|
252 | 272 | it 'accepts built in matchers' do
|
253 | 273 | expect_no_offenses(<<~RUBY)
|
254 | 274 | expect(foo).to be_truthy
|
| 275 | + expect(foo).to be_truthy, 'fail' |
255 | 276 | expect(foo).to be_falsey
|
256 | 277 | expect(foo).to be_falsy
|
257 | 278 | expect(foo).to have_attributes(name: 'foo')
|
|
275 | 296 | it 'accepts non-predicate matcher' do
|
276 | 297 | expect_no_offenses(<<~RUBY)
|
277 | 298 | expect(foo).to be(true)
|
| 299 | + expect(foo).to be(true), 'fail' |
278 | 300 | RUBY
|
279 | 301 | end
|
280 | 302 |
|
281 | 303 | it 'registers an offense for a predicate method with built-in equiv' do
|
282 | 304 | expect_offense(<<~RUBY)
|
283 | 305 | expect(foo).to be_something
|
284 | 306 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher.
|
| 307 | + expect(foo).to be_something, 'fail' |
| 308 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher. |
285 | 309 | expect(foo).not_to be_something
|
286 | 310 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `something?` over `be_something` matcher.
|
287 | 311 | expect(foo).to have_something
|
|
300 | 324 |
|
301 | 325 | expect_correction(<<~RUBY)
|
302 | 326 | expect(foo.something?).to #{matcher_true}
|
| 327 | + expect(foo.something?).to #{matcher_true}, 'fail' |
303 | 328 | expect(foo.something?).to #{matcher_false}
|
304 | 329 | expect(foo.has_something?).to #{matcher_true}
|
305 | 330 | expect(foo.is_a?(Array)).to #{matcher_true}
|
|
403 | 428 | 'with no argument' do
|
404 | 429 | expect_no_offenses(<<~RUBY)
|
405 | 430 | expect(foo).to include
|
| 431 | + expect(foo).to include, 'fail' |
406 | 432 | RUBY
|
407 | 433 | end
|
408 | 434 |
|
|
0 commit comments