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

Stubbed/Spied inherited class methods are not correctly restored after Gimme.reset #15

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jasonkarns
Copy link
Contributor

This issue has been verified on ree-1.8.7, but does not exist on ruby-1.9.3

class Parent
  def self.some_base_method; end
end
class Child < Parent; end

give(Child).some_base_method { "stubbed" }
Child.some_base_method #=> "stubbed"

Gimme.reset

Child.some_base_method #=> TypeError: singleton method bound for a different object

@jasonkarns
Copy link
Contributor Author

Added specs that expose the bug. No fix as yet.

@jasonkarns
Copy link
Contributor Author

I would love some comments on this code. I'm not sure how I feel about it. I'm especially concerned about how ruby handles & being applied to a (bound) Method. It seems to work but I feel queasy about it.

@@ -29,7 +29,7 @@ def self.destroy

context "upon reset" do
When { Gimme.reset }
Then { invocation.should raise_error }
Then { invocation.should raise_error /unimplemented feature/ }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the thinking here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to prevent false negatives. The method invocation itself should raise "unimplemented feature" when invoked. However, in cases of inherited class methods (both stubbed and spied), it was actually raising a TypeError due to the attempt of rebinding the method on the wrong object. So the tests passed, but they shouldn't have.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 5ac9ab0 on jasonkarns:restores_inherited_class_methods into * on searls:master*.

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

Successfully merging this pull request may close these issues.

3 participants