Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…rd by @nigelfds.
  • Loading branch information...
commit beb0464238c635be6ffb991ef77370fd2b46c8df 1 parent 5c61451
@seancaffery authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.