1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

A fix for the failure on an empty hash.

This commit is contained in:
Tobias Crawley 2010-04-05 14:37:22 -04:00
parent f370d82896
commit f9ff436030
2 changed files with 10 additions and 1 deletions

View file

@ -67,7 +67,7 @@ class AwesomePrint
end
end
width = data.map { |key, | key.size }.max
width = data.map { |key, | key.size }.max || 0
width += @indentation if @options[:indent] > 0
data = data.inject([]) do |arr, (key, value)|

View file

@ -124,7 +124,16 @@ EOS
before(:each) do
@hash = { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } }
end
it "empty hash" do
ap = AwesomePrint.new(:plain => true)
ap.send(:awesome, {}).should == <<-EOS.strip
{
}
EOS
end
it "plain multiline" do
ap = AwesomePrint.new(:plain => true)
ap.send(:awesome, @hash).should == <<-EOS.strip