In mock testing for stdout, `StringIO.new` is sometimes used to redirect the output.
In such cases, the assignment is done with `$stdout = StringIO.new`, not the constant `STDOUT`.
e.g., https://github.com/rubocop/rubocop/blob/v1.71.1/lib/rubocop/rspec/shared_contexts.rb#L154-L164
After assigning `StringIO.new`, `$stdout.tty?` returns `false`,
allowing the standard output destination to be switched during test execution.
```ruby
STDOUT.tty? # => true
StringIO.new.tty? # => false
```
However, since `STDOUT.tty?` returns `true`, a failure occurred in environments
where the environment variables `RUBY_PAGER` or `PAGER` are set.
e.g., https://github.com/rubocop/rubocop/pull/13784
To address this, `STDOUT` has been updated to `$stdout` so that the result of `tty?` can be flexibly overridden.
A potential concern is that `$stdout`, unlike `STDOUT`,
does not always represent the standard output at the time the Ruby process started.
However, no concrete examples of issues related to this have been identified.
`STDOUT.tty?` is the logic of optparse introduced in https://github.com/ruby/optparse/pull/70.
This PR replaces `STDOUT` with `$stdout` throughout, based on the assumption
that `$stdout` is sufficient for use with optparse.
https://github.com/ruby/optparse/commit/262cf6f9ac
```
$ make test-all TESTS=test/optparse/
...
[148/178] TestOptionParserDidYouMean#test_raise_unknown = 0.00 s
1) Failure:
TestOptionParserDidYouMean#test_raise_unknown [/home/mame/work/ruby/test/optparse/test_optparse.rb:106]:
<["--bar"]> expected but was
<[]>.
```
In the old test/unit (bundled in ruby/ruby), when a test class inherits from
another test class, the child class runs all the tests defined in the parent
class.
However, it looks like the new test/unit does not do so. This is because the
test failure does not occur in ruby/optparse.
As a tentative solution, this changes the option names in TestOptionParser to
avoid the name conflict with TestOptionParserDidYouMean.
https://github.com/ruby/optparse/commit/fee86ef7a4
Make write methods of IO-like objects accept multiple arguments,
as well as IO#write.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
When you change this to true, you may need to add more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/optparse/test_optparse.rb (TestOptionParser#assert_no_error):
prefix with assert_ so it will be skipped in backtrace.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
do not remove next argument if empty value is placed.
* test/optparse: added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e