Skip to content
Browse files

Several tests of exception handling weren't testing what they appeare…

…d to be.
  • Loading branch information...
1 parent 1a6a4ca commit 761aa74899854022b48074568869469d5a1cf9ce @danlucraft committed May 26, 2011
Showing with 19 additions and 4 deletions.
  1. +1 −0 .gitignore
  2. +10 −0 test/helper.rb
  3. +8 −4 test/test_rake_application.rb
View
1 .gitignore
@@ -12,3 +12,4 @@ r19.diff
temp_*
testdata
x
+.redcar
View
10 test/helper.rb
@@ -35,6 +35,16 @@ def ignore_deprecations
ensure
Rake.application.options.ignore_deprecate = false
end
+
+ def rake_capture_io(captured_stdout, captured_stderr)
+ orig_stdout, orig_stderr = $stdout, $stderr
+ $stdout, $stderr = captured_stdout, captured_stderr
+
+ yield
+ ensure
+ $stdout = orig_stdout
+ $stderr = orig_stderr
+ end
end
View
12 test/test_rake_application.rb
@@ -319,10 +319,12 @@ def test_bad_run
@app.intern(Rake::Task, "default").enhance { fail }
ARGV.clear
ARGV << '-f' << '-s' << '--rakelib=""'
+ out, err = StringIO.new, StringIO.new
assert_raises(SystemExit) {
- _, err = capture_io { @app.run }
- assert_match(/see full trace/, err)
+ rake_capture_io(out, err) { @app.run }
}
+ err.rewind
+ assert_match(/See full trace/, err.read)
ensure
ARGV.clear
end
@@ -331,10 +333,12 @@ def test_bad_run_with_trace
@app.intern(Rake::Task, "default").enhance { fail }
ARGV.clear
ARGV << '-f' << '-s' << '-t'
+ out, err = StringIO.new, StringIO.new
assert_raises(SystemExit) {
- _, err = capture_io { @app.run }
- refute_match(/see full trace/, err)
+ rake_capture_io(out, err) { @app.run }
}
+ err.rewind
+ refute_match(/See full trace/, err.read)
ensure
ARGV.clear
end

0 comments on commit 761aa74

Please sign in to comment.
Something went wrong with that request. Please try again.