Sha256: 3e1b0dee1fd685039abc6ea717301f8354a09cc314f4ce16abf9735b934e2c43

Contents?: true

Size: 855 Bytes

Versions: 15

Compression:

Stored size: 855 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).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).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).returns(@document)
      Mongoid::Commands::Create.execute(@document).should == @document
    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mongoid-0.10.4 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.10.3 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.10.2 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.10.1 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.10.0 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.12 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.11 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.10 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.9 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.8 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.7 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.6 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.5 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.4 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.3 spec/unit/mongoid/commands/create_spec.rb