[rspec-users] Adding Test Spy into Rspec mocking framework
lists at ruby-forum.com
Mon Sep 15 06:09:27 EDT 2008
Thanks to a pointer from lizkeogh.com site I've been discovering the joy
of the Mockito (http://mockito.org/) mocking framework for Java. It
verifies behaviour after the action. It struck me how this matched the
format I use in my Ruby cucumber features. Within Rspec if we could use
post behaviour verifications I could unify the format of my specs with
my features. Specs could look like:
it "should make verfication of behaviour after action"
setup some mock/stubs
Check whether the behaviour was as expected.
While we can do this with output checks in Rspec we cannot do such a
thing with 'should_receive'.
Having a consistent format for specs and stories sounds like a great
idea to me.
Also the separation of the verification from the Given set-up is nice.
So I'm proposing the idea of adding 'should_have_received' and test_spy
x = test_spy('like a mock but more into espionage')
#Action which does not fail on unexpected method but just records calls.
What I'm still looking at is if the idea of post validation is possible
in the Rspec framework mocking framework. I know RR
(http://github.com/btakita/rr/tree/master) is looking at implementing
the Spy pattern which will enable this sort of testing.
Do people think this would be a good addition to Rspec?
((I'm really excited with the idea and I have started playing around
with some code for a prototype. If its not for Rspec I can always look
at it for RR.))
I've added a issue in lighthouse (though its behaving very strangely at
the moment not picking my ticket up in searches/tags)
Posted via http://www.ruby-forum.com/.
More information about the rspec-users