Permalink
Browse files

fixed error raised when there are no feed entry results

  • Loading branch information...
1 parent 94a08fc commit fd9e98a106b30845102915624476227bd46d0b10 @tpitale tpitale committed May 15, 2010
Showing with 8 additions and 1 deletion.
  1. +1 −1 lib/garb/report_response.rb
  2. +7 −0 test/unit/garb/report_response_test.rb
View
2 lib/garb/report_response.rb
@@ -23,7 +23,7 @@ def parse
def entries
entry_hash = Crack::XML.parse(@xml)
- entry_hash ? [entry_hash['feed']['entry']].flatten : []
+ entry_hash ? [entry_hash['feed']['entry']].flatten.compact : []
end
def values_for(entry)
View
7 test/unit/garb/report_response_test.rb
@@ -9,6 +9,13 @@ class ReportResponseTest < MiniTest::Unit::TestCase
assert_equal ['33', '2', '1'], response.results.map(&:pageviews)
end
+
+ should "return an empty array if there are no results" do
+ response = ReportResponse.new("result xml")
+ Crack::XML.stubs(:parse).with("result xml").returns({'feed' => {'entry' => nil}})
+
+ assert_equal [], response.results
+ end
end
end
end

0 comments on commit fd9e98a

Please sign in to comment.