File tree Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class In < Default
14
14
#
15
15
# @return [ true, false ] If a value exists.
16
16
def matches? ( value )
17
- value . values . first . include? ( @attribute )
17
+ Array . wrap ( @attribute ) . any? { | e | value . values . first . include? ( e ) }
18
18
end
19
19
end
20
20
end
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class Nin < Default
14
14
#
15
15
# @return [ true, false ] If a value exists.
16
16
def matches? ( value )
17
- ! value . values . first . include? ( @attribute )
17
+ Array . wrap ( @attribute ) . none? { | e | value . values . first . include? ( e ) }
18
18
end
19
19
end
20
20
end
Original file line number Diff line number Diff line change 208
208
end
209
209
end
210
210
211
+ context "with an $in selector on Array" do
212
+
213
+ context "when the attributes match" do
214
+
215
+ let ( :selector ) do
216
+ { :services => { "$in" => [ "first" ] } }
217
+ end
218
+
219
+ it "returns true" do
220
+ document . matches? ( selector ) . should be_true
221
+ end
222
+ end
223
+
224
+ context "when the attributes do not match" do
225
+
226
+ let ( :selector ) do
227
+ { :number => { "$in" => [ "none" ] } }
228
+ end
229
+
230
+ it "returns false" do
231
+ document . matches? ( selector ) . should be_false
232
+ end
233
+ end
234
+ end
235
+
211
236
context "with an $in selector" do
212
237
213
238
context "when the attributes match" do
308
333
end
309
334
end
310
335
336
+ context "with a $nin selector on Array" do
337
+
338
+ context "when the attributes match" do
339
+
340
+ let ( :selector ) do
341
+ { :services => { "$nin" => [ "none" ] } }
342
+ end
343
+
344
+ it "returns true" do
345
+ document . matches? ( selector ) . should be_true
346
+ end
347
+ end
348
+
349
+ context "when the attributes do not match" do
350
+
351
+ let ( :selector ) do
352
+ { :services => { "$nin" => [ "first" ] } }
353
+ end
354
+
355
+ it "returns false" do
356
+ document . matches? ( selector ) . should be_false
357
+ end
358
+ end
359
+ end
360
+
311
361
context "with a $nin selector" do
312
362
313
363
context "when the attributes match" do
You can’t perform that action at this time.
0 commit comments