1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Test Kernel#quietly

This commit is contained in:
Akira Matsuda 2013-01-23 08:20:58 +09:00
parent 36ff09d7da
commit ffd0dd31f8

View file

@ -38,6 +38,18 @@ class KernelTest < ActiveSupport::TestCase
# Skip if we can't STDERR.tell
end
def test_quietly
old_stdout_position, old_stderr_position = STDOUT.tell, STDERR.tell
quietly do
puts 'see me, feel me'
STDERR.puts 'touch me, heal me'
end
assert_equal old_stdout_position, STDOUT.tell
assert_equal old_stderr_position, STDERR.tell
rescue Errno::ESPIPE
# Skip if we can't STDERR.tell
end
def test_silence_stderr_with_return_value
assert_equal 1, silence_stderr { 1 }
end