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:
parent
f370d82896
commit
f9ff436030
2 changed files with 10 additions and 1 deletions
|
@ -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)|
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue