changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/mocks/bug_report_8165_spec.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3describe "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
31end