Skip to content
Browse files

Refactored tests into non_verbose handler

[git-p4: depot-paths = "//src/minitest/dev/": change = 8027]
  • Loading branch information...
1 parent 171a623 commit 3488e8ec420cc7d1363903ab15077c490a5dedea @zenspider zenspider committed
Showing with 23 additions and 20 deletions.
  1. +23 −20 test/minitest/test_minitest_unit.rb
View
43 test/minitest/test_minitest_unit.rb
@@ -677,6 +677,15 @@ def teardown
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc._assertions
end
+ def non_verbose
+ orig_verbose = $VERBOSE
+ $VERBOSE = false
+
+ yield
+ ensure
+ $VERBOSE = orig_verbose
+ end
+
def test_assert
@assertion_count = 2
@@ -1307,36 +1316,30 @@ def test_assert_throws_unthrown
def test_capture_io
@assertion_count = 0
- orig_verbose = $VERBOSE
- $VERBOSE = false
+ non_verbose do
+ out, err = capture_io do
+ puts 'hi'
+ warn 'bye!'
+ end
- out, err = capture_io do
- puts 'hi'
- warn 'bye!'
+ assert_equal "hi\n", out
+ assert_equal "bye!\n", err
end
-
- assert_equal "hi\n", out
- assert_equal "bye!\n", err
- ensure
- $VERBOSE = orig_verbose
end
def test_capture_subprocess_io
@assertion_count = 0
skip "Dunno why but the parallel run of this fails"
- orig_verbose = $VERBOSE
- $VERBOSE = false
+ non_verbose do
+ out, err = capture_subprocess_io do
+ system("echo 'hi'")
+ system("echo 'bye!' 1>&2")
+ end
- out, err = capture_subprocess_io do
- system("echo 'hi'")
- system("echo 'bye!' 1>&2")
+ assert_equal "hi\n", out
+ assert_equal "bye!\n", err
end
-
- assert_equal "hi\n", out
- assert_equal "bye!\n", err
- ensure
- $VERBOSE = orig_verbose
end
def test_class_asserts_match_refutes

0 comments on commit 3488e8e

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