From 438e311d93f382960650e20898203c880ade6b25 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Mon, 10 Nov 2014 15:28:55 +0100 Subject: [PATCH] Add Twitter::NullObject#respond_to? Closes https://github.com/sferik/twitter/issues/614 Closes https://github.com/sferik/twitter/issues/615 --- lib/twitter/null_object.rb | 4 ++++ spec/twitter/null_object_spec.rb | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/twitter/null_object.rb b/lib/twitter/null_object.rb index e4c43b4c3..8774c1fb3 100644 --- a/lib/twitter/null_object.rb +++ b/lib/twitter/null_object.rb @@ -14,6 +14,10 @@ module Twitter # true # end + def respond_to?(*) + true + end + def instance_of?(klass) fail(TypeError.new('class or module required')) unless klass.is_a?(Class) self.class == klass diff --git a/spec/twitter/null_object_spec.rb b/spec/twitter/null_object_spec.rb index 70276d6f2..e5f76ace1 100644 --- a/spec/twitter/null_object_spec.rb +++ b/spec/twitter/null_object_spec.rb @@ -8,6 +8,12 @@ end end + describe '#respond_to?' do + it 'returns true for any method' do + expect(subject).to respond_to(:missing?) + end + end + describe '#instance_of?' do it 'returns true for Twitter::NullObject' do expect(subject.instance_of?(Twitter::NullObject)).to be true