diff --git a/lib/rspec/core/output_wrapper.rb b/lib/rspec/core/output_wrapper.rb index b655025cb..8e07aa875 100644 --- a/lib/rspec/core/output_wrapper.rb +++ b/lib/rspec/core/output_wrapper.rb @@ -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 diff --git a/spec/rspec/core/output_wrapper_spec.rb b/spec/rspec/core/output_wrapper_spec.rb index 8ed134135..031161a9f 100644 --- a/spec/rspec/core/output_wrapper_spec.rb +++ b/spec/rspec/core/output_wrapper_spec.rb @@ -1,3 +1,5 @@ +require 'socket' + module RSpec::Core RSpec.describe OutputWrapper do let(:output) { StringIO.new } @@ -9,6 +11,23 @@ module RSpec::Core expect(output.string).to eq("message\nanother message").and eq(wrapper.string) end + describe 'output method proxy' do + let(:output) {UNIXSocket.pair.first} + let(:wrapper) {OutputWrapper.new(output)} + + it "proxies IO methods to output" do + expect(output).to receive(:puts).with("message") + wrapper.puts('message') + end + + it "proxies unknown methods to output" do + expect(output).to receive(:addr).with(no_args) + wrapper.addr + end + + end + + describe '#output=' do let(:another_output) { StringIO.new }