|
21 | 21 | Band.collection.insert_one(_id: id, name: 1, likes: '1', rating: '3.1', sales: '310', decibels: '90', founded: today, updated_at: now_utc)
|
22 | 22 | Band.find(id)
|
23 | 23 | 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 |
24 | 29 |
|
25 | 30 | context 'Mongoid::RawValue<String> criteria' do
|
26 | 31 |
|
|
99 | 104 | context 'Mongoid::RawValue<Integer>' do
|
100 | 105 |
|
101 | 106 | context 'Integer field' do
|
102 |
| - it 'does not match objects with raw value' do |
| 107 | + it 'matches objects with raw value' do |
103 | 108 | expect(Band.where(likes: Mongoid::RawValue(1)).to_a).to eq [band2, band3]
|
104 | 109 | end
|
105 | 110 |
|
|
132 | 137 |
|
133 | 138 | context 'String field' do
|
134 | 139 | 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] |
136 | 141 | end
|
137 | 142 |
|
138 | 143 | it 'matches objects without raw value' do
|
|
142 | 147 |
|
143 | 148 | context 'Range field' do
|
144 | 149 | 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] |
146 | 151 | 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] |
150 | 155 | end
|
151 | 156 | end
|
152 |
| - |
| 157 | + |
153 | 158 | context 'Date field' do
|
154 | 159 | it 'does not match objects with raw value' do
|
155 | 160 | expect(Band.where(founded: Mongoid::RawValue(1577923200)).to_a).to eq []
|
|
203 | 208 | expect(Band.where(sales: 310.0).to_a).to eq [band4, band5]
|
204 | 209 | end
|
205 | 210 | end
|
206 |
| - |
| 211 | + |
207 | 212 | context 'String field' do
|
208 | 213 | 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] |
210 | 215 | end
|
211 | 216 |
|
212 | 217 | 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 [] |
214 | 219 | end
|
215 | 220 | end
|
216 |
| - |
| 221 | + |
217 | 222 | context 'Range field' do
|
218 | 223 | 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] |
220 | 225 | end
|
221 | 226 |
|
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] |
224 | 229 | end
|
225 | 230 | end
|
226 | 231 |
|
|
0 commit comments