gimme icon indicating copy to clipboard operation
gimme copied to clipboard

double does not respond to instance_of?

Open searls opened this issue 13 years ago • 4 comments

@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.

searls avatar Apr 03 '12 23:04 searls

Agreed. I have routinely had to use RSpec double in place of a gimme to get Object methods like tap.

jasonkarns avatar Feb 18 '13 02:02 jasonkarns

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.

searls avatar Feb 18 '13 04:02 searls

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?

jasonkarns avatar Mar 06 '13 22:03 jasonkarns

:+1:

searls avatar Mar 06 '13 22:03 searls