Permalink
Browse files

Simplify exception tests a bit

  • Loading branch information...
danlucraft committed May 27, 2011
1 parent 761aa74 commit 5a0cdd9199be5d880b7bb3a1269665bde9bb8cfd
Showing with 6 additions and 20 deletions.
  1. +0 −10 test/helper.rb
  2. +6 −10 test/test_rake_application.rb
View
@@ -36,16 +36,6 @@ def ignore_deprecations
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
# workarounds for 1.8
@@ -319,12 +319,10 @@ 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) {
- rake_capture_io(out, err) { @app.run }
+ _, err = capture_io {
+ assert_raises(SystemExit) { @app.run }
}
- err.rewind
- assert_match(/See full trace/, err.read)
+ assert_match(/See full trace/, err)
ensure
ARGV.clear
end
@@ -333,12 +331,10 @@ 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) {
- rake_capture_io(out, err) { @app.run }
+ _, err = capture_io {
+ assert_raises(SystemExit) { @app.run }
}
- err.rewind
- refute_match(/See full trace/, err.read)
+ refute_match(/See full trace/, err)
ensure
ARGV.clear
end

0 comments on commit 5a0cdd9

Please sign in to comment.