This isn't really an rspec question, but about mocks and stubs in
general, and maybe I'm looking for some best practices with rspec.
I like mocks and stubs until code starts to change, and then I always
get frustrated because examples then seem so brittle and sensitive to
implementation details, which feels wrong to me.
So a small example: this is in an example for a Discount model:
@order.should_receive(:line_items).and_return(mock_model(LineItem,
:size => 2))
(@order is a mock; I realize it maybe should just be a stub)
The key expectation in this example is:
@discount.should_not be_available(@order)
But I changed the implementation of Discount#available? so that it calls
Order#num_products instead of Order#line_items. My examples now fail.
Why am I having trouble getting comfortable with this?
Thanks,
dwh
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users