Kernel.warn when using Forwardable delegators with a null object
Created by: bannable
Subject of the issue
When using Forwardable delegators, if the destination object is a spy, a kernel warning will be emitted of the form:
warning: [Class]#[method name] at [file]:[line] forwarding to private method RSpec::Mocks::InstanceVerifyingDouble#[method name]
Your environment
- Ruby version:
- rspec-mocks version:
Steps to reproduce
require 'forwardable'
require 'rspec/core'
require 'rspec/mocks'
class ForwardableTest
extend Forwardable
def_delegator :@dest, :bar
def initialize(dest)
@dest = dest
end
def foo
bar
end
end
class Injected
def bar; true; end
end
RSpec.describe 'fowardable behavior' do
subject { ForwardableTest.new(thing).bar }
context 'with an object instance' do
let(:thing) { Injected.new }
specify { expect { subject }.not_to output.to_stderr }
end
context 'with a null object (spy)' do
let(:thing) { instance_spy('Injected') }
specify { expect { subject }.not_to output.to_stderr }
end
end
Expected behavior
Both examples will pass.
Actual behavior
fowardable behavior with a null object (spy) is expected not to output to stderr
fails.