Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Use __send__ instead of send
Browse files Browse the repository at this point in the history
  • Loading branch information
richardplatel committed Jul 27, 2023
1 parent 8158970 commit 9fc8f5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/rspec/core/output_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ def respond_to?(name, priv=false)
end

def method_missing(name, *args, &block)
output.send(name, *args, &block)
output.__send__(name, *args, &block)
end

# Redirect calls for IO interface methods
IO.instance_methods(false).each do |method|
define_method(method) do |*args, &block|
output.send(method, *args, &block)
output.__send__(method, *args, &block)
end
end
end
Expand Down
15 changes: 12 additions & 3 deletions spec/rspec/core/output_wrapper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
require 'socket'

module RSpec::Core
RSpec.describe OutputWrapper do
let(:output) { StringIO.new }
let(:socket_pair) { UNIXSocket.pair }
let(:output) { socket_pair.first }
let(:destination) {socket_pair.last}
let(:wrapper) { OutputWrapper.new(output) }

it 'redirects calls to the wrapped object' do
it 'redirects IO method calls to the wrapped object' do
wrapper.puts('message')
wrapper.print('another message')
expect(output.string).to eq("message\nanother message").and eq(wrapper.string)
expect(destination.recv(32)).to eq("message\nanother message")
end

it 'redirects unknown method calls to the wrapped object' do
expect(output).to receive(:addr).with(no_args)
wrapper.addr
end

describe '#output=' do
Expand Down

0 comments on commit 9fc8f5a

Please sign in to comment.