Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rb][spec] ruby3.2: redirect stdout directly instead of using Logger.… #11499

Closed

Conversation

mtasaka
Copy link

@mtasaka mtasaka commented Dec 31, 2022

…reopen

In selenium rb rspec test suite, rspec mocks File.exist? method partway. With ruby3.2, this may confuse ::Logger.new using $stdout as output because of IO class being changed to accept #path method. Then it may close $stdout with ::Logger.reopen via have_deprecated rspec matcher defined in selenium internally.

So when using have_deprecated matcher defined inside selenium, instead of using Logger.reopen, redirect stdout directly, using Tempfile and reopen $stdout directly.

Also, as said above, with ruby 3.2 IO also accepts #path method, so IO#path.exists? is now valid on ruby3.2. This affects 'uses the given jar file and port' testsuite in spec/unit/selenium/server_spec.rb: File class must be mocked so that #exist? method accepts also '` argument.

Closes #11498 .

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • [x ] I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…reopen

In selenium rb rspec test suite, rspec mocks `File.exist?` method partway.
With ruby3.2, this may confuse `::Logger.new` using `$stdout` as output because of
`IO` class being changed to accept `#path` method.
Then it may close `$stdout` with `::Logger.reopen` via `have_deprecated` rspec
matcher defined in selenium internally.

So when using have_deprecated matcher defined inside selenium, instead of using
Logger.reopen, redirect stdout directly, using `Tempfile` and reopen `$stdout`
directly.

Also, as said above, with ruby 3.2 `IO` also accepts `#path` method, so
`IO#path.exists?` is now valid on ruby3.2. This affects 'uses the given jar file and port'
testsuite in spec/unit/selenium/server_spec.rb: `File` class must be mocked
so that `#exist?` method accepts also '<STDOUT>` argument.

Closes SeleniumHQ#11498 .
@CLAassistant
Copy link

CLAassistant commented Dec 31, 2022

CLA assistant check
All committers have signed the CLA.

@titusfortner
Copy link
Member

Thanks for going through all of this and making the PR. I got everything working with this instead: 590cfbb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: [rb] rspec spec/unit aborts with ruby3.2
3 participants