Skip to content

Commit

Permalink
NullObject#as_json returns ‘null’
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Morris authored and sferik committed Apr 23, 2015
1 parent 69675f5 commit 2979e70
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 @@ -41,5 +41,9 @@ def <=>(other)
def nil?
true
end

def as_json
'null'
end
end
end
6 changes: 6 additions & 0 deletions spec/twitter/null_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
end
end

describe '#as_json' do
it "returns 'null'" do
expect(subject.as_json).to eq('null')
end
end

describe 'black hole' do
it 'returns self for missing methods' do
expect(subject.missing).to eq(subject)
Expand Down

0 comments on commit 2979e70

Please sign in to comment.