Skip to content
Browse files

fix bug where there is less than 10 of a statistic to return. Discove…

…rd by @nigelfds.
  • Loading branch information...
1 parent 5c61451 commit beb0464238c635be6ffb991ef77370fd2b46c8df @seancaffery committed Nov 1, 2011
Showing with 11 additions and 4 deletions.
  1. +4 −4 lib/stepdown/statistics.rb
  2. +7 −0 spec/lib/stepdown/statistics_spec.rb
View
8 lib/stepdown/statistics.rb
@@ -27,7 +27,7 @@ def to_h
end
def groupings_rest
- groupings[10..groupings.length]
+ groupings[10..groupings.length] || []
end
def groupings_top(limit = 10)
@@ -98,7 +98,7 @@ def usages_top(limit = 10)
end
def usages_rest
- usages[10..usages.length]
+ usages[10..usages.length] || []
end
def step_usages
@@ -110,7 +110,7 @@ def usages
end
def unused_rest
- unused[10..unused.length]
+ unused[10..unused.length] || []
end
def unused_top(limit = 10)
@@ -145,7 +145,7 @@ def steps_scenario(scenarios)
end
def empty_rest
- empty[10..empty.length]
+ empty[10..empty.length] || []
end
def empty_top(limit = 10)
View
7 spec/lib/stepdown/statistics_spec.rb
@@ -234,6 +234,13 @@
end
end
+ methods.each do |method|
+ it "should not break if there are not enough elements for a requested collection" do
+ @stats.stub!(method.to_sym).and_return([])
+ @stats.send("#{method}_rest".to_sym).should be_empty
+ end
+ end
+
end
end

0 comments on commit beb0464

Please sign in to comment.
Something went wrong with that request. Please try again.