diff --git a/lib/prawn/grid.rb b/lib/prawn/grid.rb index 80cd9e268..4912edadc 100644 --- a/lib/prawn/grid.rb +++ b/lib/prawn/grid.rb @@ -145,12 +145,12 @@ def subdivide(total, num, gutter) def apply_gutter(options) if options.key?(:gutter) - @gutter = Float(options[:gutter]) + @gutter = Float(options.fetch(:gutter, 0.0)) @row_gutter = @gutter @column_gutter = @gutter else - @row_gutter = Float(options[:row_gutter]) - @column_gutter = Float(options[:column_gutter]) + @row_gutter = Float(options.fetch(:row_gutter, 0.0)) + @column_gutter = Float(options.fetch(:column_gutter, 0.0)) @gutter = 0 end end diff --git a/spec/prawn/document_grid_spec.rb b/spec/prawn/document_grid_spec.rb index 94f77ad67..4c79e1d6b 100644 --- a/spec/prawn/document_grid_spec.rb +++ b/spec/prawn/document_grid_spec.rb @@ -13,6 +13,13 @@ expect(pdf.grid.gutter).to eq(0.1) end + it 'allows definition of a grid without gutter' do + pdf.define_grid(columns: 3, rows: 5) + expect(pdf.grid.columns).to eq(3) + expect(pdf.grid.rows).to eq(5) + expect(pdf.grid.gutter).to eq(0.0) + end + it 'allows re-definition of a grid' do pdf.define_grid(columns: 5, rows: 8, gutter: 0.1) expect(pdf.grid.columns).to eq(5)