Created
November 16, 2012 20:15
-
-
Save mkb/4090511 to your computer and use it in GitHub Desktop.
Avoid printing directly to stdout to make testing easier.
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 | |
def bar(outstream) | |
outstream.puts "BAZ" | |
end | |
end |
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 'foo' | |
describe Foo do | |
let(:foo) { Foo.new } | |
let(:outstream) { StringIO.new } | |
it 'outputs bar' do | |
foo.bar(outstream) | |
outstream.string.should match(/baz/i) | |
end | |
end |
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
#!/usr/bin/env ruby | |
$: << '.' | |
require 'foo' | |
foo = Foo.new | |
foo.bar(STDOUT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment