-
-
Notifications
You must be signed in to change notification settings - Fork 766
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
Use __send__ instead of send #3045
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a spec that would fail with send, but would work with send?
d3d6aec
to
3495630
Compare
@@ -9,6 +9,11 @@ module RSpec::Core | |||
expect(output.string).to eq("message\nanother message").and eq(wrapper.string) | |||
end | |||
|
|||
it 'proxies IO instance methods with __send__ to be compatiable with IOs that redefine send' do | |||
expect(output).to receive(:__send__).with(:puts, 'message') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please accept my apologies for not making myself clear.
Would it be possible to add a real-world case here that would fail with send
but would work with __send__
? TCPSocket
or others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking at my PR @pirj!
How about this test?
e4e4591
to
31220b3
Compare
31220b3
to
9fc8f5a
Compare
@pirj Could use some help here figuring out how to write this test. Seems like making a real TCPSocket is not ideal but I'm not sure how to mock it in a way that still tests the change. Or maybe there another approach? |
Thanks for spotting this, I've merged your commit with an updated spec. (0ff6358) |
This has been released in 3.12.3, sorry about the delay |
RSpec::Core::OutputWrapper uses
send
to call class methods onIO
objects, but someIO
objects (e.g.TCPSocket
) redefinesend
. Use the equivalent__send__
method instead.https://apidock.com/ruby/BasicObject/__send__