mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00

Replace use of `STDIN`, `STDOUT` and `STDERR` constants by their
`$stdin`, `$stdout` and `$stderr` global variable equivalents.
This enables easier testing via standard means, such as `assert_output`
for minitest or `expect { print 'foo' }.to output.to_stdout` for RSpec
test suites.
a0a6fc1b76
19 lines
496 B
Ruby
19 lines
496 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "helper"
|
|
require "rubygems/user_interaction"
|
|
|
|
class TestGemConsoleUI < Gem::TestCase
|
|
def test_output_can_be_captured_by_test_unit
|
|
output = capture_output do
|
|
ui = Gem::ConsoleUI.new
|
|
|
|
ui.alert_error "test error"
|
|
ui.alert_warning "test warning"
|
|
ui.alert "test alert"
|
|
end
|
|
|
|
assert_equal "INFO: test alert\n", output.first
|
|
assert_equal "ERROR: test error\n" + "WARNING: test warning\n", output.last
|
|
end
|
|
end
|