Sha256: b7174896cbbc03c41b0c3ce404a8f17b072f7fe1387217ef7b178643a33c1b1e
Contents?: true
Size: 1.35 KB
Versions: 9
Compression:
Stored size: 1.35 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" } } end it "deletes each document that the criteria finds" do @klass.expects(:collection).returns(@collection) @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 end it "drops the collection" do @klass.expects(:collection).returns(@collection) @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 end it "drops the collection" do @klass.expects(:collection).returns(@collection) @collection.expects(:remove).with({ :_type => "Person" }, { :safe => true }) Mongoid::Commands::DeleteAll.execute(@klass, {}) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems