tristandunn / pusher-fake

A fake Pusher server for development and testing.
https://rubygems.org/gems/pusher-fake
MIT License
173 stars 32 forks source link

Issue when using `rspec` with `--bisect` option #66

Closed pucinsk closed 3 years ago

pucinsk commented 3 years ago

Description When I run rspec with --bisect option enabled then I get an error regarding $stdout usage.

Error

bundle exec rspec --bisect spec/any_spec.rb
...
# pusher-fake/lib/pusher-fake/configuration.rb:53:in `reset!'
NoMethodError:
  undefined method `to_io' for #<StringIO:0x00007fa3e189ecc0>
  Did you mean?  to_s
                 to_a
                 to_h

This error occurs because RSpec::Core::Bisect::ForkRunner overrides $stdout with StringIO here.

Any ideas how it could be fixed? 🙏

Versions:

rspec 3.10
pusher-fake 3.0.0

Thank you for your time

tristandunn commented 3 years ago

Good catch and thanks for letting me know. The fix might be as easy as a condition to verify the object responds to to_io:

-      self.logger   = $stdout.to_io
+      self.logger   = $stdout.respond_to?(:to_io) ? $stdout.to_io : $stdout

I'll dig into it more tonight and hopefully get a fix out.

Related, I found an old Ruby bug, #5479, that discusses adding StringIO#to_io but looks like it was rejected 10 years ago.

tristandunn commented 3 years ago

@pucinsk Just released 3.0.1 to GitHub and RubyGems. Let me know if you have any more issues.

pucinsk commented 3 years ago

Thank you very much @tristandunn ! rspec --bisect works. All good!