spec/mongo/collection_spec.rb in mongo-2.0.4 vs spec/mongo/collection_spec.rb in mongo-2.0.5
- old
+ new
@@ -260,9 +260,22 @@
it 'returns a authorized_collection view with an empty selector' do
expect(view.selector).to be_empty
end
end
+ context 'when providing a bad selector' do
+
+ let(:view) do
+ authorized_collection.find('$or' => [])
+ end
+
+ it 'raises an exception when iterating' do
+ expect {
+ view.to_a
+ }.to raise_exception(Mongo::Error::OperationFailure)
+ end
+ end
+
context 'when iterating the authorized_collection view' do
before do
authorized_collection.insert_many([{ field: 'test1' }, { field: 'test2' }])
end