Sha256: c184f4af2eee216b4c251b13d6e07d65810d0270330c899f2678975c8b7c8164
Contents?: true
Size: 1.11 KB
Versions: 7
Compression:
Stored size: 1.11 KB
Contents
require 'spec_helper' describe 'CRUD operations' do let(:collection) { authorized_client['crud_integration'] } before do collection.delete_many end describe 'upsert' do context 'with default write concern' do it 'upserts' do collection.count_documents({}).should == 0 res = collection.find(_id: 'foo').update_one({'$set' => {foo: 'bar'}}, upsert: true) res.documents.first['upserted'].length.should == 1 collection.count_documents({}).should == 1 end end context 'unacknowledged write' do let(:unack_collection) do collection.with(write_concern: {w: 0}) end before do unack_collection.write_concern.acknowledged?.should be false end it 'upserts' do unack_collection.count_documents({}).should == 0 res = unack_collection.find(_id: 'foo').update_one({'$set' => {foo: 'bar'}}, upsert: true) # since write concern is unacknowledged, wait for the data to be # persisted (hopefully) sleep 0.25 unack_collection.count_documents({}).should == 1 end end end end
Version data entries
7 entries across 7 versions & 1 rubygems