Created
November 21, 2010 23:51
-
-
Save mwotton/709304 to your computer and use it in GitHub Desktop.
stubbing new
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
require 'rspec' | |
class Bar | |
def baz | |
puts "baz called" | |
end | |
end | |
class Foo | |
def initialize | |
@bar = Bar.new | |
@bar.baz | |
end | |
end | |
describe "stubbing an init" do | |
it 'should stub' do | |
@mymock = mock("mymock") | |
Bar.stub(:new).and_return(@mymock) | |
@mymock.should_receive(:baz) | |
Foo.new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment