Created
February 26, 2012 18:59
-
-
Save robie1373/1918282 to your computer and use it in GitHub Desktop.
How to test puts in a method
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
describe Putter do | |
describe "#start" do | |
it "should say i put" do | |
output = double('output') | |
putter = Putter.new | |
output.should_receive(:puts).with('i put') | |
putter.start | |
end | |
end | |
end | |
class Putter | |
def initialize | |
@output = STDOUT | |
end | |
def start | |
@output.puts "i put" | |
end | |
end | |
=begin | |
1) EchoBaseDirs Putter#start should say i put | |
Failure/Error: output.should_receive(:puts).with('i put') | |
(Double "output").puts("i put") | |
expected: 1 time | |
received: 0 times | |
rspec (2.8.0) | |
rspec-core (2.8.0) | |
rspec-expectations (2.8.0) | |
rspec-mocks (2.8.0) | |
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0] | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment