On 12.4.2008, at 14.06, roberto belardo wrote:
Uhm ok, i understood your answer but autotest did not. Better, this do not solves the problem. If i simply remove the "stub" and the "should_receive" for the author field, autotest will complain like this: Spec::Mocks::MockExpectationError in 'CommentsController handling POST /comments should create a new comment' Mock 'Comment_1008' received unexpected message :author= with (#<User:0x..fdb98f624 @name="User_1006">) and this was the reason why i put the "should_receive" and the "stub" on "author=" method, as someone told previously on this ml. :( Is there someone who knows how to spec this? Help needed.
Two ways:1) either use Comment.new instead of mock_model(Comment) in your before block. This way your comment object has the ability to assign its author. 2) Use the mock model and your should_receive test. However, after that you cannot test that @comment.author.should be(@user) because you have stubbed author= and it doesn't really do anything. So you just have to rely on that it works (like you should since it's Rails code which you shouldn't really be testing).
//jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users