Permalink
Browse files

Merge branch 'fix-exception-tests' into add-cron-option

Conflicts:
	test/test_rake_application.rb
  • Loading branch information...
2 parents e7ae66c + 5a0cdd9 commit 28cc06636034b22973cf521c650c8c3f20ea0937 @danlucraft committed May 27, 2011
Showing with 11 additions and 29 deletions.
  1. +0 −10 test/helper.rb
  2. +11 −19 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,14 +331,11 @@ 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
- err_s = err.read
- refute_match(/See full trace/, err_s)
- assert_match(/application.rb/, err_s)
+ refute_match(/See full trace/, err)
+ assert_match(/application.rb/, err)
ensure
ARGV.clear
end
@@ -349,14 +344,11 @@ def test_bad_run_with_cron
@app.intern(Rake::Task, "default").enhance { fail }
ARGV.clear
ARGV << '-f' << '-s' << '-c'
- 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
- err_s = err.read
- refute_match(/See full trace/, err_s)
- assert_match(/application.rb/, err_s)
+ refute_match(/See full trace/, err)
+ assert_match(/application.rb/, err)
ensure
ARGV.clear
end

0 comments on commit 28cc066

Please sign in to comment.