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

Posted by Derick Bailey on Stack Overflow See other posts from Stack Overflow or by Derick Bailey
Published on 2009-10-18T01:47:26Z Indexed on 2010/05/15 19:24 UTC
Read the original article Hit count: 253

Filed under:
|
|

I'm trying to use rspec's mocking to setup expectations that I can verify in the it "should" methods... but I don't know how to do this... when i call the .should_receive methods on the mock, it verifies the expected call as soon as the before :all method exits.

here's a small example:

describe Foo, "when doing something" do
 before :all do
  Bar.should_recieve(:baz)
  foo = Foo.new
  foo.create_a_Bar_and_call_baz
 end

 it "should call the bar method" do
  # ??? what do i do here?
 end
end

How can i verify the expected call in the 'it "should"' method? do i need to use mocha or another mocking framework instead of rspec's? or ???

© Stack Overflow or respective owner

Related posts about rspec

Related posts about mocking