Sha256: 3810731b554ca55c1ef20b9cf7e869b3f085ec606ef64c611b22c86749f3473c

Contents?: true

Size: 907 Bytes

Versions: 3

Compression:

Stored size: 907 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
      @document.expects(:run_callbacks).yields
      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(:create).yields
      Mongoid::Commands::Save.expects(:execute).with(@document, true).returns(@document)
      Mongoid::Commands::Create.execute(@document)
    end

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

  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
mongoid-pre-2.0.0.beta1 spec/unit/mongoid/commands/create_spec.rb
mongoid-2.0.0.alpha spec/unit/mongoid/commands/create_spec.rb
mongoid-pre-2.0.0.pre spec/unit/mongoid/commands/create_spec.rb