Sha256: ba92d0ad50321d888e158b1d039ee2ca3c413cf27a445fc446f79b39b55dc3d3

Contents?: true

Size: 903 Bytes

Versions: 24

Compression:

Stored size: 903 Bytes

Contents

require File.join(File.dirname(__FILE__), "/../../../spec_helper.rb")

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

24 entries across 24 versions & 1 rubygems

Version Path
mongoid-0.6.4 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.6.3 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.6.2 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.6.1 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.6.0 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.11 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.10 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.9 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.8 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.7 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.6 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.5 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.4 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.3 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.2 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.1 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.5.0 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.4.8 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.4.7 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.4.5 spec/unit/mongoid/commands/create_spec.rb