Skip to content

Commit

Permalink
fix bug with rendering empty hash
Browse files Browse the repository at this point in the history
  • Loading branch information
cldwalker committed Mar 26, 2011
1 parent d56762b commit fb22b16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/hirb/helpers/table/resizer.rb
Expand Up @@ -75,8 +75,8 @@ def remaining_width(field)
end

def sum(arr)
arr.inject {|t,e| t += e }
arr.inject {|t,e| t += e } || 0
end
#:startdoc:
end
end
end
12 changes: 12 additions & 0 deletions test/table_test.rb
Expand Up @@ -54,6 +54,18 @@ def table(*args)
table([{'a'=>1, 'b'=>2}, {'a'=>3, 'b'=>4}]).should == expected_table
end

it "with no keys renders" do
expected_table = <<-TABLE.unindent
+--+
| |
+--+
| |
+--+
1 row in set
TABLE
table([{}]).should == expected_table
end

it "with array only rows renders" do
expected_table = <<-TABLE.unindent
+---+---+
Expand Down

0 comments on commit fb22b16

Please sign in to comment.