From 2979e703c09a45f012cb2c5b2d6663bf1f4d3351 Mon Sep 17 00:00:00 2001 From: Luke Morris Date: Thu, 26 Mar 2015 16:59:21 -0700 Subject: [PATCH] =?UTF-8?q?NullObject#as=5Fjson=20returns=20=E2=80=98null?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 8774c1fb3..a8cc952d6 100644 --- a/lib/twitter/null_object.rb +++ b/lib/twitter/null_object.rb @@ -41,5 +41,9 @@ def <=>(other) def nil? true end + + def as_json + 'null' + end end end diff --git a/spec/twitter/null_object_spec.rb b/spec/twitter/null_object_spec.rb index e5f76ace1..ea64cf0d2 100644 --- a/spec/twitter/null_object_spec.rb +++ b/spec/twitter/null_object_spec.rb @@ -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)