spec/support/shared_mongo_adapter.rb in adapter-mongo-0.8.0 vs spec/support/shared_mongo_adapter.rb in adapter-mongo-0.8.1

- old
+ new

@@ -3,33 +3,33 @@ it "allows using object id's as keys in correct type" do id = BSON::ObjectId.new attributes = {'one' => 'two'} adapter.write(id, attributes) - client.find_one('_id' => id).should_not be_nil - adapter.read(id).should == attributes + expect(client.find_one('_id' => id)).not_to be_nil + expect(adapter.read(id)).to eq(attributes) end it "allows using ordered hashes as keys" do key = BSON::OrderedHash['d', 1, 'n', 1] attributes = {'one' => 'two'} adapter.write(key, attributes) - client.find_one('_id' => key).should_not be_nil - adapter.read(key).should == attributes + expect(client.find_one('_id' => key)).not_to be_nil + expect(adapter.read(key)).to eq(attributes) end it "allows using hashes as keys" do key = {:d => 1} attributes = {'one' => 'two'} adapter.write(key, attributes) - client.find_one('_id' => key).should_not be_nil - adapter.read(key).should == attributes + expect(client.find_one('_id' => key)).not_to be_nil + expect(adapter.read(key)).to eq(attributes) end it "stores hashes right in document" do adapter.write('foo', 'steak' => 'bacon') - client.find_one('_id' => 'foo').should == {'_id' => 'foo', 'steak' => 'bacon'} + expect(client.find_one('_id' => 'foo')).to eq({'_id' => 'foo', 'steak' => 'bacon'}) end describe "with safe option" do context "set to true" do before do @@ -41,20 +41,20 @@ client.drop_index('email_1') end it "does not raise operation failure on write if operation succeeds" do adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - lambda { + expect { adapter.write(BSON::ObjectId.new, {'email' => 'steve@orderedlist.com'}) - }.should_not raise_error(Mongo::OperationFailure) + }.not_to raise_error end it "raises operation failure on write if operation fails" do adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - lambda { + expect { adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - }.should raise_error(Mongo::OperationFailure) + }.to raise_error(Mongo::OperationFailure) end end context "set to false" do before do @@ -66,20 +66,20 @@ client.drop_index('email_1') end it "does not raise operation failure on write if operation succeeds" do adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - lambda { + expect { adapter.write(BSON::ObjectId.new, {'email' => 'steve@orderedlist.com'}) - }.should_not raise_error(Mongo::OperationFailure) + }.not_to raise_error end it "does not raise operation failure on write if operation fails" do adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - lambda { + expect { adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - }.should_not raise_error(Mongo::OperationFailure) + }.not_to raise_error end end end describe "with :write_concern" do @@ -92,53 +92,53 @@ client.drop_index('email_1') end it "does not raise operation failure on write if operation succeeds" do adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - lambda { + expect { adapter.write(BSON::ObjectId.new, {'email' => 'steve@orderedlist.com'}) - }.should_not raise_error(Mongo::OperationFailure) + }.not_to raise_error end it "raises operation failure on write if operation fails" do adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - lambda { + expect { adapter.write(BSON::ObjectId.new, {'email' => 'john@orderedlist.com'}) - }.should raise_error(Mongo::OperationFailure) + }.to raise_error(Mongo::OperationFailure) end it "allows overriding write concern for write" do id = BSON::ObjectId.new - client.should_receive(:update). + expect(client).to receive(:update). with( hash_including(:_id), kind_of(Hash), hash_including(:w => 0) ) adapter.write(id, {:foo => 'bar'}, :w => 0) end it "uses write concern for delete" do id = BSON::ObjectId.new - client.should_receive(:remove).with({:_id => id}, :w => 1) + expect(client).to receive(:remove).with({:_id => id}, :w => 1) adapter.delete(id) end it "allows overriding write concern for delete" do id = BSON::ObjectId.new - client.should_receive(:remove).with({:_id => id}, :w => 0) + expect(client).to receive(:remove).with({:_id => id}, :w => 0) adapter.delete(id, :w => 0) end it "uses write concern for clear" do id = BSON::ObjectId.new - client.should_receive(:remove).with({}, :w => 1) + expect(client).to receive(:remove).with({}, :w => 1) adapter.clear end it "allows overriding write concern for clear" do id = BSON::ObjectId.new - client.should_receive(:remove).with({}, :w => 0) + expect(client).to receive(:remove).with({}, :w => 0) adapter.clear(:w => 0) end end end