From 9d904a18ec50486489f5533bced4a13ebbc89318 Mon Sep 17 00:00:00 2001 From: Wynn Netherland Date: Mon, 12 Aug 2013 15:20:56 -0500 Subject: [PATCH] Twitter::Error.errors lists descendants recursively --- lib/twitter/error.rb | 3 ++- spec/twitter/error_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/twitter/error.rb b/lib/twitter/error.rb index c30ec19e1..fdd1bab78 100644 --- a/lib/twitter/error.rb +++ b/lib/twitter/error.rb @@ -17,7 +17,8 @@ def self.from_response(response={}) # @return [Hash] def self.errors @errors ||= descendants.each_with_object({}) do |klass, hash| - hash[klass::HTTP_STATUS_CODE] = klass + hash[klass::HTTP_STATUS_CODE] = klass if defined?(klass::HTTP_STATUS_CODE) + hash.update(klass.errors) end end diff --git a/spec/twitter/error_spec.rb b/spec/twitter/error_spec.rb index 34b865658..3b84c6324 100644 --- a/spec/twitter/error_spec.rb +++ b/spec/twitter/error_spec.rb @@ -17,4 +17,10 @@ end end + describe "#errors" do + it "lists descendant errors" do + expect(Twitter::Error.errors).to have_key(403) + end + end + end