Sha256: 7b17533e1bf013b8c94e57559e0e7811afef97547da9f3509e0e81237eb975b1

Contents?: true

Size: 1.21 KB

Versions: 96

Compression:

Stored size: 1.21 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

describe "An object where respond_to? is true and does not have method" do
  # When should_receive(:sym) is sent to any object, the Proxy sends
  # respond_to?(:sym) to that object to see if the method should be proxied.
  #
  # If respond_to? itself is proxied, then when the Proxy sends respond_to?
  # to the object, the proxy is invoked and responds yes (if so set in the spec).
  # When the object does NOT actually respond to :sym, an exception is thrown
  # when trying to proxy it.
  #
  # The fix was to keep track of whether :respond_to? had been proxied and, if
  # so, call the munged copy of :respond_to? on the object.

  it "should not raise an exception for Object" do
    obj = Object.new
    obj.should_receive(:respond_to?).with(:foobar).and_return(true)
    obj.should_receive(:foobar).and_return(:baz)
    obj.respond_to?(:foobar).should be_true
    obj.foobar.should == :baz
  end

  it "should not raise an exception for mock" do
    obj = mock("obj")
    obj.should_receive(:respond_to?).with(:foobar).and_return(true)
    obj.should_receive(:foobar).and_return(:baz)
    obj.respond_to?(:foobar).should be_true
    obj.foobar.should == :baz
  end

end

Version data entries

96 entries across 96 versions & 13 rubygems

Version Path
dchelimsky-rspec-1.1.10 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.11.1 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.11.2 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.11.3 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.11.4 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.11.5 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.11.6 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.11.7 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.11 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.12 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.1 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.13 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.2 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.3 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.4 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.5 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.6 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.7 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.8 spec/spec/mocks/bug_report_8165_spec.rb
dchelimsky-rspec-1.1.99.9 spec/spec/mocks/bug_report_8165_spec.rb