]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/mocks/bug_report_8165_spec.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / mocks / bug_report_8165_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
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.
6   #
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.
11   #
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.
14
15   it "should not raise an exception for Object" do
16     obj = Object.new
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
21   end
22
23   it "should not raise an exception for mock" do
24     obj = mock("obj")
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
29   end
30
31 end