Created
January 14, 2014 20:42
-
-
Save zombor/8425298 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
end | |
class Foobar < Foo | |
end | |
describe 'foo' do | |
it 'works weird' do | |
Foo.should_receive(:new) | |
Foobar.new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd expect that to pass. Here's why:
Foo
, in this case), so that it can respond to that message based on how you've configured it (e.g.and_return
,and_raise
, etc).Foobar.new
, so whenFoobar
receives thenew
message, it goes up the ancestor chain to find a definition.Class#new
, but becauseFoo.new
exists now, it finds that first, and executes it.I can see why this would be confusing, but hopefully that makes sense.