mocking - rspec mocks: verify expectations in it "should" methods? -


I'm trying to use rspec jokes to set expectations, which I want in "should" methods I can verify ... but I do not know how to do this ... When I call on the fake .should_receive methods, then it confirms the expected call as before: all the methods come out.

Here's a small example:

  Describe Fu, "Do everything before doing anything": All do the times. Should_recieve (: baz) Foo = Foo.new foo.create_a_Bar_and_call_baz What should I call "bar method"? What do I do here? And end  

I want the call to 'this' How can I verify "method"? Do I need to use any other joke instead of Mocha or RSPC? Or ???

I'm going to take another strange on this, because it is clear from the initial one and the set of responses that there was some confusion about what you are trying to do. Doing this is close to what you are trying to do.

  Describe FU, "when the first is frozen: Do all @ Foo.new #bar to make a tap object to say it to ignore those methods Which we have not explicitly set stub or expectations on # stubbed / stub ("A Bar"). As_null_object Bar.stub! (: New) .and_return (@bar) After the end: Do it.frob each! Finish it "Once" dot @ bar.Should_Reserve (: Zap!), "Bar it twice" twice daily. Shield_Reserve (: Frootz!) ​​End End  

Incidentally, though it works I Bar.stub! (: New) is not a big fan of the pattern; I usually prefer to pass collaborators through alternative arguments, e.g. @ it.frob! (@trip) . When no explicit argument (such as in the output code) is given, the collaborator may be the default: DRF free! (Bar = bar.new) . This does not keep the test too low for internal implementation.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -