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

David Chelimsky dchelimsky at gmail.com
Thu Jun 10 12:57:29 EDT 2010


On Thu, Jun 10, 2010 at 11:38 AM, Kristian Mandrup <kmandrup at gmail.com> wrote:
> 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?

assigns(:message).should eq(@message)

HTH,
David

>
>    Failure/Error: assigns[:message].should == @message
>    expected: #<Message:0x819b4318 @name="Message_1005">,
>         got: nil (using ==)
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list