Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rubygems/rubygems] Use globals variables for standard input/output
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. rubygems/rubygems@a0a6fc1b76
- Loading branch information
Showing
2 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# 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 |