1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
3 describe "An object where respond_to? is true and does not have method" do
4 # When should_receive(:sym) is sent to any object, the Proxy sends
5 # respond_to?(:sym) to that object to see if the method should be proxied.
7 # If respond_to? itself is proxied, then when the Proxy sends respond_to?
8 # to the object, the proxy is invoked and responds yes (if so set in the spec).
9 # When the object does NOT actually respond to :sym, an exception is thrown
10 # when trying to proxy it.
12 # The fix was to keep track of whether :respond_to? had been proxied and, if
13 # so, call the munged copy of :respond_to? on the object.
15 it "should not raise an exception for Object" do
17 obj.should_receive(:respond_to?).with(:foobar).and_return(true)
18 obj.should_receive(:foobar).and_return(:baz)
19 obj.respond_to?(:foobar).should be_true
20 obj.foobar.should == :baz
23 it "should not raise an exception for mock" do
25 obj.should_receive(:respond_to?).with(:foobar).and_return(true)
26 obj.should_receive(:foobar).and_return(:baz)
27 obj.respond_to?(:foobar).should be_true
28 obj.foobar.should == :baz