spec/mongoid/criteria/queryable/selector_spec.rb in mongoid-7.0.4 vs spec/mongoid/criteria/queryable/selector_spec.rb in mongoid-7.0.5
- old
+ new
@@ -839,6 +839,43 @@
it "returns the selector in a $match entry" do
expect(pipeline).to eq([{ "$match" => { "name" => "test" }}])
end
end
end
+
+ describe '#multi_selection?' do
+
+ let(:selector) do
+ described_class.new
+ end
+
+ context 'when key is $and' do
+ it 'returns true' do
+ expect(selector.send(:multi_selection?, '$and')).to be true
+ end
+ end
+
+ context 'when key is $or' do
+ it 'returns true' do
+ expect(selector.send(:multi_selection?, '$or')).to be true
+ end
+ end
+
+ context 'when key is $nor' do
+ it 'returns true' do
+ expect(selector.send(:multi_selection?, '$nor')).to be true
+ end
+ end
+
+ context 'when key includes $or but is not $or' do
+ it 'returns false' do
+ expect(selector.send(:multi_selection?, '$ore')).to be false
+ end
+ end
+
+ context 'when key is some other ey' do
+ it 'returns false' do
+ expect(selector.send(:multi_selection?, 'foo')).to be false
+ end
+ end
+ end
end