|
55 | 55 | end
|
56 | 56 |
|
57 | 57 | it 'does not match objects without raw value' do
|
58 |
| - expect(Band.where(name: '90').to_a).to eq [] |
| 58 | + expect(Band.where(decibels: '90').to_a).to eq [] |
59 | 59 | end
|
60 | 60 | end
|
61 | 61 |
|
|
121 | 121 | end
|
122 | 122 |
|
123 | 123 | it 'does not match objects without raw value' do
|
124 |
| - expect(Band.where(name: 90).to_a).to eq [] |
| 124 | + expect(Band.where(decibels: 90).to_a).to eq [] |
125 | 125 | end
|
126 | 126 | end
|
127 | 127 |
|
|
185 | 185 | end
|
186 | 186 |
|
187 | 187 | it 'does not match objects without raw value' do
|
188 |
| - expect(Band.where(name: 90.0).to_a).to eq [] |
| 188 | + expect(Band.where(decibels: 90.0).to_a).to eq [] |
189 | 189 | end
|
190 | 190 | end
|
191 | 191 |
|
|
210 | 210 | end
|
211 | 211 | end
|
212 | 212 | end
|
| 213 | + |
| 214 | + context 'Mongoid::RawValue<Range>' do |
| 215 | + |
| 216 | + context 'Integer field' do |
| 217 | + it 'does not match objects' do |
| 218 | + expect(Band.where(likes: Mongoid::RawValue(0..2)).to_a).to eq [] |
| 219 | + end |
| 220 | + |
| 221 | + it 'matches objects without raw value' do |
| 222 | + expect(Band.where(likes: 0..2).to_a).to eq [band1, band2, band3, band4] |
| 223 | + end |
| 224 | + end |
| 225 | + |
| 226 | + context 'Float field' do |
| 227 | + it 'does not match objects' do |
| 228 | + expect(Band.where(rating: Mongoid::RawValue(1..3)).to_a).to eq [] |
| 229 | + end |
| 230 | + |
| 231 | + it 'matches objects without raw value' do |
| 232 | + expect(Band.where(rating: 1..3).to_a).to eq [band2, band3] |
| 233 | + end |
| 234 | + end |
| 235 | + |
| 236 | + context 'String field' do |
| 237 | + it 'matches objects' do |
| 238 | + expect(Band.where(name: Mongoid::RawValue(1..3)).to_a).to eq [] |
| 239 | + end |
| 240 | + |
| 241 | + it 'matches objects without raw value' do |
| 242 | + expect(Band.where(name: 1..3).to_a).to eq [band1, band2, band3, band4] |
| 243 | + end |
| 244 | + end |
| 245 | + |
| 246 | + context 'Range field' do |
| 247 | + it 'does not match objects' do |
| 248 | + expect(Band.where(decibels: Mongoid::RawValue(30..90)).to_a).to eq [band2] |
| 249 | + expect(Band.where(decibels: Mongoid::RawValue(20..100)).to_a).to eq [] |
| 250 | + end |
| 251 | + |
| 252 | + it 'does not match objects without raw value' do |
| 253 | + expect(Band.where(decibels: 30..90).to_a).to eq [] |
| 254 | + expect(Band.where(decibels: 20..100).to_a).to eq [] |
| 255 | + end |
| 256 | + end |
| 257 | + |
| 258 | + context 'Date field' do |
| 259 | + it 'does not match objects' do |
| 260 | + expect(Band.where(founded: Mongoid::RawValue(1577923199..1577923201)).to_a).to eq [] |
| 261 | + end |
| 262 | + |
| 263 | + # TODO: this isn't working for some reason -- returns all bands |
| 264 | + xit 'matches objects without raw value' do |
| 265 | + expect(Band.where(founded: 1577923199..1577923201).to_a).to eq [band3, band4] |
| 266 | + end |
| 267 | + end |
| 268 | + |
| 269 | + context 'Time field' do |
| 270 | + it 'does not match objects' do |
| 271 | + expect(Band.where(updated_at: Mongoid::RawValue(1578153599..1578153600)).to_a).to eq [] |
| 272 | + end |
| 273 | + |
| 274 | + # TODO: this isn't working for some reason |
| 275 | + xit 'matches objects without raw value' do |
| 276 | + expect(Band.where(updated_at: 1578153599..1578153600).to_a).to eq [band4, band5] |
| 277 | + end |
| 278 | + end |
| 279 | + end |
213 | 280 | end
|
0 commit comments