Created
August 5, 2010 13:05
-
-
Save Vaguery/509700 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Even with the added strengths of Ruby 1.9.2, it turns out to be tricky to write a Cucumber | |
| # story that specifies something like | |
| # | |
| # "Then no warning message should be produced" | |
| # | |
| # As a holdover until I find something safer, I've had to redirect Ruby's $stderr stream | |
| # to a StringIO instance, examine that in the step definition, and reset it to the STDERR | |
| # default after the fact. | |
| require 'stringio' | |
| Before do | |
| @mistakes = StringIO.open('','r+') | |
| $stderr = @mistakes | |
| end | |
| After do | |
| $stderr = STDERR | |
| end | |
| ... | |
| Then /^no warning message should be produced$/ do | |
| @mistakes.rewind | |
| @mistakes.read.should == "" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment