I've been doing further work on adding the Test Spy to the RR mocking framework.
During my background research I came across a Spy like mocking framework called 'Not A Mock' by Pete Yandell. This comes with Rspec hooks. It uses a similar syntax to what we have discussed here and as Pat mentioned does some of this through a Rspec Matcher: >object.should have_received(:length).without_args.and_returned(42) >object.should have_received(:name).twice It works on real objects or stub objects and you have to register the methods to track: >object.track_methods(:name, :length) http://notahat.com/not_a_mock http://github.com/notahat/not_a_mock/tree/master Thought this might be of interest to you Pat. -- Joseph Wilk http://www.joesniff.co.uk Pat Maddox wrote: > On Mon, Sep 15, 2008 at 8:43 AM, David Chelimsky <[EMAIL PROTECTED]> > wrote: >>>> x.should_have_received(:method).and_returned_with('some string') >>> >>> I actually started implementing this the day before Dan posted that. >>> It works, but I don't have all the nice error messages and stuff yet. >>> Will take me a couple days to get around to finishing it probably. >> >> Have you implemented this within the mock framework or as a separate concept? > > It's just a new matcher. I did mess with the mock framework a little > in that I record calls every time it receives a message, rather than > only when it hits method_missing. > > I will be restructuring the mock internals to better support this, I > think. But of course it won't change the public API, and mocks will > still have the fail-fast behavior by default if that's what you want. > > Basic example of what I'm doing... > > o = stub("stub", :foo => true) > o.foo > o.should have_received(:foo) > > It's not a true spy in the sense that it accepts any message (you can > use :null_object for that). My only desire here was to unify the > format of interaction-based tests with the arrange/act/assert format > typical of state-based tests. > > Pat -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users