Sha256: bcd12b2784060db7956d18f8978120e7930901341b101573393eae5d7ef60e3a

Contents?: true

Size: 893 Bytes

Versions: 13

Compression:

Stored size: 893 Bytes

Contents

require "spec_helper"

describe Mongoid::Commands::DeleteAll do

  describe "#execute" do

    before do
      @doc = mock
      @docs = [@doc]
      @klass = mock
    end

    context "when conditions supplied" do

      before do
        @conditions = { :conditions => { :title => "Sir" } }
      end

      it "deletes each document that the criteria finds" do
        @klass.expects(:find).with(:all, @conditions).returns(@docs)
        Mongoid::Commands::Delete.expects(:execute).with(@doc)
        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(:drop)
        Mongoid::Commands::DeleteAll.execute(@klass)
      end

    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mongoid-0.10.5 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.10.4 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.10.3 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.10.2 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.10.1 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.10.0 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.9.12 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.9.11 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.9.10 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.9.9 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.9.8 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.9.7 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.9.6 spec/unit/mongoid/commands/delete_all_spec.rb