Skip to content

Commit

Permalink
Refactored tests into non_verbose handler
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/minitest/dev/": change = 8027]
  • Loading branch information
zenspider committed Nov 29, 2012
1 parent 171a623 commit 3488e8e
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions test/minitest/test_minitest_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3488e8e

Please sign in to comment.