gimme
gimme copied to clipboard
double does not respond to instance_of?
@marick raises a great point.
Grr. A mock object should be an `instance_of?` the class it's mocking.
Initially I erred on the side of gimme being a complete blank slate, but there are a number of basic methods on Object that should be implemented.
Agreed. I have routinely had to use RSpec double in place of a gimme to get Object methods like tap.
tap is a good example of a method that makes sense to be on the double object, because it raises another concern—since doubles are currently blank slates, I wonder if delegating responses to a bunch of built-in object methods could potentially break any existing specs in subtle/surprising ways.
Another oft-needed method is ==. I routinely attempt its(:whatever) { should == some_double} and have to fall back to an rspec double in order to get basic equality.
Perhaps this is a candidate for an API-breaking version bump? Alternatively, we could take a page from RSpec's book. In RSpec, in order to get a null-type object (like a gimme), one can use double.as_null_object. Perhaps we could do the reverse. Something like gimme.as_standard_object?
:+1: