Sha256: 8053f3112733643dc9b53ebcbd667bd71360f1182507eba67ee4b9ffb41268da
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
require "spec_helper" describe Mongoid::Commands::DeleteAll do describe "#execute" do before do @doc = mock @docs = [@doc] @klass = stub(:name => "Person") end context "when conditions supplied" do before do @collection = mock @conditions = { :conditions => { :title => "Sir" } } @cursor = stub(:count => 30) end it "deletes each document that the criteria finds" do @klass.expects(:collection).returns(@collection) @collection.expects(:find).with(@conditions[:conditions].merge(:_type => "Person")).returns(@cursor) @collection.expects(:remove).with(@conditions[:conditions].merge(:_type => "Person"), :safe => true) Mongoid::Commands::DeleteAll.execute(@klass, @conditions) end end context "when no conditions supplied" do before do @collection = mock @cursor = stub(:count => 30) end it "drops the collection" do @klass.expects(:collection).returns(@collection) @collection.expects(:find).with({ :_type => "Person" }).returns(@cursor) @collection.expects(:remove).with({ :_type => "Person" }, { :safe => true }) Mongoid::Commands::DeleteAll.execute(@klass) end end context "when empty conditions supplied" do before do @collection = mock @cursor = stub(:count => 30) end it "drops the collection" do @klass.expects(:collection).returns(@collection) @collection.expects(:find).with({ :_type => "Person" }).returns(@cursor) @collection.expects(:remove).with({ :_type => "Person" }, { :safe => true }) Mongoid::Commands::DeleteAll.execute(@klass, {}) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-pre-2.0.0.beta1 | spec/unit/mongoid/commands/delete_all_spec.rb |