Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double does not respond to instance_of? #8

Open
searls opened this issue Apr 3, 2012 · 4 comments
Open

double does not respond to instance_of? #8

searls opened this issue Apr 3, 2012 · 4 comments

Comments

@searls
Copy link
Owner

searls commented Apr 3, 2012

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

@jasonkarns
Copy link
Contributor

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

@searls
Copy link
Owner Author

searls commented Feb 18, 2013

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.

@jasonkarns
Copy link
Contributor

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?

@searls
Copy link
Owner Author

searls commented Mar 6, 2013

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants