Brian Takita wrote:
On Sun, Sep 21, 2008 at 11:17 AM, Joseph Wilk <[EMAIL PROTECTED]> wrote:
I've been doing further work on adding the Test Spy to the RR mocking
framework.
Awesome! Do you have a clone available?
I'm not quite ready to push my work up to Github. I've been trying lots of spikes experimenting with what a spy means in RR. I'll let you know as soon as I push my work up to github.

I'll share my thoughts so far on what I think RR's interpretation of a Spy could be. In the traditional sense a spy is a stub object that records method invocations.

But RR is all about taking real objects and using double injection. It feels out of place to introduce a stub object as a spy. So the direction I've been leaning towards is a spy should be a real object that logs its calls. Those calls follow the real implementation. You can still stub the spy.

This feels like the most natural solution for RR, though its much harder to implement than just a stub object :)

@@@
class Example
 def shout(words)
   "#{words}!"
 end
end

example = Example.new
spy(example)

example.shout("monkeys")
>> "monkeys!"

verify(example).shout("monkeys")
@@@

Whats your opinion Brian? Anyone else?

Oh, I've really enjoyed going through RR's source and I've learnt a lot from it, thanks!
--
Joseph Wilk
http://www.joesniff.co.uk


_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to