| Path: | TODO |
| Last Update: | Tue Aug 19 13:26:37 +1000 2008 |
Currently calls to methods that throw exceptions are not recorded. It would be good if they were, and if assertions could be made against them, e.g.
object.should have_received(:gsub).and_raised(ArgumentError)
You can‘t stub or record calls for methods that take blocks. This is very difficult to fix in Ruby 1.8, but will be much easier in 1.9.
Error messages are pretty smart already. If I call:
object.should have_received(:gsub).with("Hello", "Goodbye").and_returned("Goodbye, world!")
I might get an error like:
Object received gsub, but not with arguments ["Hello", "Goodbye"].
It would be much more useful if the error message told you the arguments it actually received as well.
I should be able to write something like this to assert that the calls happened in order:
in_order do
object_a.should have_received(:message_a)
object_b.should have_received(:message_b)
object_a.should have_received(:message_c)
end
I often find myself doing something like this before a test:
@comment = Comment.stub_object(:body => "Great!") @comments = Object.stub_object(:find => [@comment]) @article = Article.stub_object(:title => "Hello, world!", :comments => @comments) Article.stub_method(:find => @article)
I‘d like to find a way to make this neater, auto-generate the stub relationship, etc.