Sha256: 984237c8d8cea7d472dd56098b469d2cf03711f0818f68dfa691410cee6f65d5

Contents?: true

Size: 873 Bytes

Versions: 39

Compression:

Stored size: 873 Bytes

Contents

require "spec_helper"

describe Mongoid::Commands::Create do

  describe "#execute" do

    before do
      @document = stub(:run_callbacks)
    end

    it "executes a save command" do
      Mongoid::Commands::Save.expects(:execute).with(@document, true).returns(@document)
      Mongoid::Commands::Create.execute(@document)
    end

    it "runs the before and after create callbacks" do
      @document.expects(:run_callbacks).with(:before_create)
      Mongoid::Commands::Save.expects(:execute).with(@document, true).returns(@document)
      @document.expects(:run_callbacks).with(:after_create)
      Mongoid::Commands::Create.execute(@document)
    end

    it "returns the document" do
      Mongoid::Commands::Save.expects(:execute).with(@document, true).returns(@document)
      Mongoid::Commands::Create.execute(@document).should == @document
    end

  end

end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
mongoid-1.2.14 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.13 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.12 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.11 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.10 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.9 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.8 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.7 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.6 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.5 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.4 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.3 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.2 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.1 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.2.0 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.1.4 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.1.3 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.1.2 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.1.1 spec/unit/mongoid/commands/create_spec.rb
mongoid-1.0.6 spec/unit/mongoid/commands/create_spec.rb