Skip to content

Commit

Permalink
Use __send__ instead of send
Browse files Browse the repository at this point in the history
  • Loading branch information
richardplatel authored and JonRowe committed Aug 5, 2023
1 parent dd5b489 commit 0fbdf73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 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
8 changes: 8 additions & 0 deletions spec/rspec/core/output_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ module RSpec::Core
expect(output.string).to eq("message\nanother message").and eq(wrapper.string)
end

it 'redirects calls when send is overridden' do
class << output
undef :send
end
wrapper.puts('message')
expect(output.string).to eq("message\n").and eq(wrapper.string)
end

describe '#output=' do
let(:another_output) { StringIO.new }

Expand Down

0 comments on commit 0fbdf73

Please sign in to comment.