Sha256: 930b409d8bbd8edf82e208d47b2e5ca8f097f05e995a9dbfd0bd823c757db0e9

Contents?: true

Size: 921 Bytes

Versions: 30

Compression:

Stored size: 921 Bytes

Contents

require File.expand_path(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

30 entries across 30 versions & 1 rubygems

Version Path
mongoid-0.9.2 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.1 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.9.0 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.10 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.9 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.8 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.7 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.6 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.5 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.4 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.3 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.2 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.8.1 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.7.10 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.7.9 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.7.8 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.7.7 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.7.6 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.7.5 spec/unit/mongoid/commands/create_spec.rb
mongoid-0.7.4 spec/unit/mongoid/commands/create_spec.rb