|
74 | 74 | expect(Band.where(decibels: Mongoid::RawValue('90')).to_a).to eq [band6]
|
75 | 75 | end
|
76 | 76 |
|
77 |
| - it 'matches objects because String cannot be evolved to Range' do |
| 77 | + it 'matches objects without raw value because String cannot be evolved to Range' do |
78 | 78 | expect(Band.where(decibels: '90').to_a).to eq [band6]
|
79 | 79 | end
|
80 | 80 | end
|
|
150 | 150 | expect(Band.where(decibels: Mongoid::RawValue(90)).to_a).to eq [band7]
|
151 | 151 | end
|
152 | 152 |
|
153 |
| - it 'matches objects because Integer cannot be evolved to Range' do |
| 153 | + it 'matches objects without raw value because Integer cannot be evolved to Range' do |
154 | 154 | expect(Band.where(decibels: 90).to_a).to eq [band7]
|
155 | 155 | end
|
156 | 156 | end
|
|
224 | 224 | expect(Band.where(decibels: Mongoid::RawValue(90.0)).to_a).to eq [band7]
|
225 | 225 | end
|
226 | 226 |
|
227 |
| - it 'matches objects because Float cannot be evolved to Range' do |
| 227 | + it 'matches objects without raw value because Float cannot be evolved to Range' do |
228 | 228 | expect(Band.where(decibels: 90.0).to_a).to eq [band7]
|
229 | 229 | end
|
230 | 230 | end
|
|
289 | 289 |
|
290 | 290 | context 'String field' do
|
291 | 291 | it 'matches objects with raw value' do
|
292 |
| - expect(Band.where(name: Mongoid::RawValue(BigDecimal('3'))).to_a).to eq [] |
| 292 | + expect(Band.where(name: Mongoid::RawValue(BigDecimal('1'))).to_a).to eq [band6, band7] |
293 | 293 | end
|
294 | 294 |
|
295 |
| - it 'matches objects without raw value' do |
296 |
| - expect(Band.where(name: BigDecimal('3')).to_a).to eq [] |
| 295 | + it 'does not match objects without raw value' do |
| 296 | + expect(Band.where(name: BigDecimal('1')).to_a).to eq [] |
297 | 297 | end
|
298 | 298 | end
|
299 | 299 |
|
300 | 300 | context 'Range field' do
|
301 |
| - it 'does not match objects with raw value' do |
302 |
| - expect(Band.where(decibels: Mongoid::RawValue(BigDecimal('90'))).to_a).to eq [] |
| 301 | + it 'matches objects with raw value' do |
| 302 | + expect(Band.where(decibels: Mongoid::RawValue(BigDecimal('90'))).to_a).to eq [band7] |
303 | 303 | end
|
304 | 304 |
|
305 |
| - it 'does not match objects without raw value' do |
306 |
| - expect(Band.where(decibels: BigDecimal('90')).to_a).to eq [] |
| 305 | + it 'matches objects without raw value because BigDecimal cannot be evolved to Range' do |
| 306 | + expect(Band.where(decibels: BigDecimal('90')).to_a).to eq [band7] |
307 | 307 | end
|
308 | 308 | end
|
309 | 309 |
|
|
376 | 376 | expect { Band.where(decibels: Mongoid::RawValue(30..90)).to_a }.to raise_error BSON::Error::UnserializableClass
|
377 | 377 | end
|
378 | 378 |
|
379 |
| - it 'does not match objects without raw value' do |
380 |
| - expect(Band.where(decibels: 30..90).to_a).to eq [] |
381 |
| - expect(Band.where(decibels: 20..100).to_a).to eq [] |
| 379 | + it 'matches objects without raw value because Range is evolved into a gte/lte query range' do |
| 380 | + expect(Band.where(decibels: 30..90).to_a).to eq [band7] |
| 381 | + expect(Band.where(decibels: 20..100).to_a).to eq [band7] |
382 | 382 | end
|
383 | 383 | end
|
384 | 384 |
|
|
0 commit comments