[rspec-users] RSpec 2 equivalent for: assigns[:message].should == @message

Kristian Mandrup kmandrup at gmail.com
Thu Jun 10 11:38:17 EDT 2010


describe MessagesController, "POST create" do

  before(:each) do
    @message = mock_model(Message, :save => nil)
    Message.stub(:new).and_return(@message)
  end


  context "when the message fails to save" do
    before(:each) do
      @message.stub(:save).and_return(false)
    end

    it "assigns @message" do
      post :create
      assigns[:message].should == @message
    end

---
What is the RSpec 2 equivalent for assigns[:message].should ==
@message in this context?

    Failure/Error: assigns[:message].should == @message
    expected: #<Message:0x819b4318 @name="Message_1005">,
         got: nil (using ==)


More information about the rspec-users mailing list