Skip to content

Instantly share code, notes, and snippets.

@Vaguery
Created August 5, 2010 13:05
Show Gist options
  • Select an option

  • Save Vaguery/509700 to your computer and use it in GitHub Desktop.

Select an option

Save Vaguery/509700 to your computer and use it in GitHub Desktop.
# 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