Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

double.as_null_object always returns true for respond_to?

- Closes #16.
  • Loading branch information...
commit 972deb535fc76a91959e48696e91a69f0231e768 1 parent 9003244
@dchelimsky dchelimsky authored
View
4 lib/rspec/mocks/mock.rb
@@ -34,6 +34,10 @@ def to_s
alias_method :to_str, :to_s
+ def respond_to?(sym, incl_private=false)
+ __mock_proxy.respond_to?(sym, incl_private)
+ end
+
private
def method_missing(sym, *args, &block)
View
4 lib/rspec/mocks/proxy.rb
@@ -37,6 +37,10 @@ def initialize(object, name=nil, options={})
def null_object?
@null_object
end
+
+ def respond_to?(sym, incl_private=false)
+ null_object? ? true : super
+ end
# Tells the object to ignore any messages that aren't explicitly set as
# stubs or message expectations.
View
4 spec/rspec/mocks/null_object_mock_spec.rb
@@ -35,6 +35,10 @@ module Mocks
@mock.message(:expected_arg)
@mock.message(:unexpected_arg)
end
+
+ it "responds to everything" do
+ @mock.should respond_to(:any_message_it_gets)
+ end
end
describe "#null_object?" do
Please sign in to comment.
Something went wrong with that request. Please try again.