Skip to content

Commit a5e1875

Browse files
committed
Specs WIP
1 parent 40ea586 commit a5e1875

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

spec/integration/criteria/raw_value_spec.rb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
Band.collection.insert_one(_id: id, name: 1, likes: '1', rating: '3.1', sales: '310', decibels: '90', founded: today, updated_at: now_utc)
2222
Band.find(id)
2323
end
24+
let!(:band7) do
25+
id = BSON::ObjectId.new
26+
Band.collection.insert_one(_id: id, name: 1.0, decibels: 90.0)
27+
Band.find(id)
28+
end
2429

2530
context 'Mongoid::RawValue<String> criteria' do
2631

@@ -99,7 +104,7 @@
99104
context 'Mongoid::RawValue<Integer>' do
100105

101106
context 'Integer field' do
102-
it 'does not match objects with raw value' do
107+
it 'matches objects with raw value' do
103108
expect(Band.where(likes: Mongoid::RawValue(1)).to_a).to eq [band2, band3]
104109
end
105110

@@ -132,7 +137,7 @@
132137

133138
context 'String field' do
134139
it 'matches objects with raw value' do
135-
expect(Band.where(name: Mongoid::RawValue(3)).to_a).to eq []
140+
expect(Band.where(name: Mongoid::RawValue(1)).to_a).to eq [band6, band7]
136141
end
137142

138143
it 'matches objects without raw value' do
@@ -142,14 +147,14 @@
142147

143148
context 'Range field' do
144149
it 'does not match objects with raw value' do
145-
expect(Band.where(decibels: Mongoid::RawValue(90)).to_a).to eq []
150+
expect(Band.where(decibels: Mongoid::RawValue(90)).to_a).to eq [band7]
146151
end
147-
148-
it 'does not match objects without raw value' do
149-
expect(Band.where(decibels: 90).to_a).to eq []
152+
153+
it 'matches objects because Integer cannot be evolved to Range' do
154+
expect(Band.where(decibels: 90).to_a).to eq [band7]
150155
end
151156
end
152-
157+
153158
context 'Date field' do
154159
it 'does not match objects with raw value' do
155160
expect(Band.where(founded: Mongoid::RawValue(1577923200)).to_a).to eq []
@@ -203,24 +208,24 @@
203208
expect(Band.where(sales: 310.0).to_a).to eq [band4, band5]
204209
end
205210
end
206-
211+
207212
context 'String field' do
208213
it 'matches objects with raw value' do
209-
expect(Band.where(name: Mongoid::RawValue(3.0)).to_a).to eq []
214+
expect(Band.where(name: Mongoid::RawValue(1.0)).to_a).to eq [band6, band7]
210215
end
211216

212217
it 'matches objects without raw value' do
213-
expect(Band.where(name: 3.0).to_a).to eq []
218+
expect(Band.where(name: 1.0).to_a).to eq []
214219
end
215220
end
216-
221+
217222
context 'Range field' do
218223
it 'does not match objects with raw value' do
219-
expect(Band.where(decibels: Mongoid::RawValue(90.0)).to_a).to eq []
224+
expect(Band.where(decibels: Mongoid::RawValue(90.0)).to_a).to eq [band7]
220225
end
221226

222-
it 'does not match objects without raw value' do
223-
expect(Band.where(decibels: 90.0).to_a).to eq []
227+
it 'matches objects because Float cannot be evolved to Range' do
228+
expect(Band.where(decibels: 90.0).to_a).to eq [band7]
224229
end
225230
end
226231

0 commit comments

Comments
 (0)