On Aug 25, 2009, at 5:13 PM, Tom Stuart wrote:
On 25 Aug 2009, at 20:59, Chuck Remes wrote:
The documentation says the expectation passes or fails based upon
the return value of the block. I can't even force it to fail by
returning false.
The docs (http://rspec.info/documentation/mocks/message_expectations.html
) say:
You can supply a block to a message expectation. When the message
is received
by the mock, the block is passed any arguments and evaluated. The
result is
the return value of the block.
This means that the mocked method will return the value that is
returned by the block; by returning false in your block, you're just
arranging for the mocked method to return false. (So this is the
same as @api.should_receive(:publish_to_bus).and_return(false).)
If you want the message expectation to fail, you need to put a
failing expectation inside the block.
Setting an expectation within the block makes it work. I think the
docs should be clearer that the expectations inside are necessary.
cr
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users