spec/unit/designs/migrations_spec.rb in couchrest_model-2.1.0.rc1 vs spec/unit/designs/migrations_spec.rb in couchrest_model-2.2.0.beta1

- old
+ new

@@ -32,28 +32,28 @@ @doc = @mod.design_doc @db = @mod.database end it "should create new design if non exists" do - @db.should_receive(:view).with("#{@doc.name}/#{@doc['views'].keys.first}", { + expect(@db).to receive(:view).with("#{@doc.name}/#{@doc['views'].keys.first}", { :limit => 1, :stale => 'update_after', :reduce => false }) callback = @doc.migrate do |res| - res.should eql(:created) + expect(res).to eql(:created) end doc = @db.get(@doc['_id']) - doc['views']['all'].should eql(@doc['views']['all']) - callback.should be_nil + expect(doc['views']['all']).to eql(@doc['views']['all']) + expect(callback).to be_nil end it "should not change anything if design is up to date" do @doc.sync - @db.should_not_receive(:view) + expect(@db).not_to receive(:view) callback = @doc.migrate do |res| - res.should eql(:no_change) + expect(res).to eql(:no_change) end - callback.should be_nil + expect(callback).to be_nil end end describe "migrating a document if there are changes" do @@ -70,31 +70,31 @@ @doc.create_view(:by_name_and_surname) @doc_id = @doc['_id'] + '_migration' end it "should save new migration design doc" do - @db.should_receive(:view).with("#{@doc.name}_migration/by_name", { + expect(@db).to receive(:view).with("#{@doc.name}_migration/by_name", { :limit => 1, :reduce => false, :stale => 'update_after' }) @callback = @doc.migrate do |res| - res.should eql(:migrated) + expect(res).to eql(:migrated) end - @callback.should_not be_nil + expect(@callback).not_to be_nil # should not have updated original view until cleanup doc = @db.get(@doc['_id']) - doc['views'].should_not have_key('by_name_and_surname') + expect(doc['views']).not_to have_key('by_name_and_surname') # Should have created the migration new_doc = @db.get(@doc_id) - new_doc.should_not be_nil + expect(new_doc).not_to be_nil # should be possible to perform cleanup @callback.call expect(@db.get(@doc_id)).to be_nil doc = @db.get(@doc['_id']) - doc['views'].should have_key('by_name_and_surname') + expect(doc['views']).to have_key('by_name_and_surname') end end end