Using stderr instead of stdout

This commit is contained in:
Parker Moore 2014-05-06 13:15:19 -04:00
parent a7776f8279
commit 4c55c77c04
2 changed files with 13 additions and 3 deletions

View File

@ -70,4 +70,14 @@ class Test::Unit::TestCase
ensure
$stdout = $old_stdout
end
def capture_stderr
$old_stderr = $stderr
$stderr = StringIO.new
yield
$stderr.rewind
return $stderr.string
ensure
$stderr = $old_stderr
end
end

View File

@ -21,7 +21,7 @@ class TestConvertible < Test::Unit::TestCase
should "not parse if there is syntax error in front-matter" do
name = 'broken_front_matter2.erb'
out = capture_stdout do
out = capture_stderr do
ret = @convertible.read_yaml(@base, name)
assert_equal({}, ret)
end
@ -30,7 +30,7 @@ class TestConvertible < Test::Unit::TestCase
end
should "not allow ruby objects in yaml" do
out = capture_stdout do
out = capture_stderr do
@convertible.read_yaml(@base, 'exploit_front_matter.erb')
end
assert_no_match /undefined class\/module DoesNotExist/, out
@ -38,7 +38,7 @@ class TestConvertible < Test::Unit::TestCase
should "not parse if there is encoding error in file" do
name = 'broken_front_matter3.erb'
out = capture_stdout do
out = capture_stderr do
ret = @convertible.read_yaml(@base, name, :encoding => 'utf-8')
assert_equal({}, ret)
end