Skip to content

Commit

Permalink
Add Twitter::NullObject#respond_to?
Browse files Browse the repository at this point in the history
Closes #614
Closes #615
  • Loading branch information
sferik committed Nov 10, 2014
1 parent 83145c9 commit 438e311
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/twitter/null_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/twitter/null_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 438e311

Please sign in to comment.