Sha256: cdf0df77a9b7ca3734c88903d4344baeb95686eaa9450c586365306a975a7545

Contents?: true

Size: 1.17 KB

Versions: 34

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

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 "does 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 "does not raise an exception for mock" do
    obj = double("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

34 entries across 34 versions & 4 rubygems

Version Path
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/spec/rspec/mocks/bug_report_8165_spec.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.6.0 spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.6.0.rc6 spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.6.0.rc4 spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.6.0.rc2 spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.5.0 spec/rspec/mocks/bug_report_8165_spec.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.4.0 spec/rspec/mocks/bug_report_8165_spec.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/bug_report_8165_spec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/bug_report_8165_spec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.3.0 spec/rspec/mocks/bug_report_8165_spec.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/bug_report_8165_spec.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/bug_report_8165_spec.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.2.0 spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.1.0 spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.0.1 spec/rspec/mocks/bug_report_8165_spec.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/spec/rspec/mocks/bug_report_8165_spec.rb