Skip to content

Commit ef140b6

Browse files
committed
Integration spec
1 parent 1984d7a commit ef140b6

File tree

1 file changed

+70
-3
lines changed

1 file changed

+70
-3
lines changed

spec/integration/criteria/raw_value_spec.rb

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
end
5656

5757
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 []
5959
end
6060
end
6161

@@ -121,7 +121,7 @@
121121
end
122122

123123
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 []
125125
end
126126
end
127127

@@ -185,7 +185,7 @@
185185
end
186186

187187
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 []
189189
end
190190
end
191191

@@ -210,4 +210,71 @@
210210
end
211211
end
212212
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
213280
end

0 commit comments

Comments
 (0)