Sha256: f68872d0a6bfb27d16b916e901bfffa7304e2448f0aff7b1bdebe900ad8d5780

Contents?: true

Size: 1.2 KB

Versions: 43

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe "An object where respond_to? is true and does not have method" do
  # When should_receive(message) is sent to any object, the Proxy sends
  # respond_to?(message) 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 `message`, 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)
    expect(obj.respond_to?(:foobar)).to be_true
    expect(obj.foobar).to eq :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)
    expect(obj.respond_to?(:foobar)).to be_true
    expect(obj.foobar).to eq :baz
  end

end

Version data entries

43 entries across 43 versions & 14 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-mocks-2.14.6/spec/rspec/mocks/bug_report_8165_spec.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-mocks-2.13.0/spec/rspec/mocks/bug_report_8165_spec.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-mocks-2.14.4/spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.14.6 spec/rspec/mocks/bug_report_8165_spec.rb
rspec-mocks-2.14.5 spec/rspec/mocks/bug_report_8165_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-mocks-2.14.4/spec/rspec/mocks/bug_report_8165_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-mocks-2.14.4/spec/rspec/mocks/bug_report_8165_spec.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-mocks-2.14.4/spec/rspec/mocks/bug_report_8165_spec.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/spec/rspec/mocks/bug_report_8165_spec.rb
tuktuk-rails-0.0.9 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/spec/rspec/mocks/bug_report_8165_spec.rb
tuktuk-rails-0.0.8 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/spec/rspec/mocks/bug_report_8165_spec.rb
tuktuk-rails-0.0.7 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/spec/rspec/mocks/bug_report_8165_spec.rb