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 Mar 27, 2015
1 parent c5cf178 commit 0f8bd7e
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
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
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 0f8bd7e

Please sign in to comment.