Kristian Mandrup
2010-Jun-10 15:38 UTC
[rspec-users] RSpec 2 equivalent for: assigns[:message].should == @message
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 ==)
David Chelimsky
2010-Jun-10 16:57 UTC
[rspec-users] RSpec 2 equivalent for: assigns[:message].should == @message
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 >