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

unstub fails with subclasses #69

Closed
jreeves opened this issue Aug 4, 2011 · 4 comments
Closed

unstub fails with subclasses #69

jreeves opened this issue Aug 4, 2011 · 4 comments

Comments

@jreeves
Copy link

jreeves commented Aug 4, 2011

If you unstub a parent class and then a child class, the child class will be given methods from the parent. e.g.

irb> require 'rspec'
irb> RSpec::Mocks::setup(Object.new)
irb> class Foo; end
irb> class Bar < Foo; end
irb> Foo.stub(:new)
irb> Bar.stub(:new)
irb> Foo.unstub(:new)
irb> Bar.unstub(:new)
irb> Bar.new
=> #<Foo:0x101ec4cd8>
aakashd added a commit to aakashd/rspec-mocks that referenced this issue Jun 9, 2012
@aakashd
Copy link
Contributor

aakashd commented Jun 9, 2012

I have written a spec which verifies the issue and explains my understanding of how the API should behave. Please verify if it's correct. I will start working on the issue.

@aakashd
Copy link
Contributor

aakashd commented Jun 9, 2012

Also, if I change the sequence of stubbing, it works perfectly fine.

Child.stub(:new)
Parent.stub(:new)
Child.unstub(:new)
Parent.unstub(:new)
Child.new.should be_an_instance_of Child

I don't yet know exactly what it means, but it's a start.

@jreeves
Copy link
Author

jreeves commented Jun 11, 2012

That spec looks like it'll correctly test the issue.

@alindeman
Copy link
Contributor

I believe this was inadvertently fixed by a727464. I've added the spec from @aakashd to prevent its regression.

Thanks for the report and spec.

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

3 participants