Browse Source

Merge pull request #96 from meltheadorable/bugfix/column-size-bug

fixes #56 by accounting for case that would produce zero rows
dev
Andy Meneely 11 years ago
parent
commit
3354bf9b27
  1. 4
      lib/squib/input_helpers.rb
  2. 15
      spec/input_helpers_spec.rb

4
lib/squib/input_helpers.rb

@ -221,8 +221,12 @@ module Squib
def rowify(opts)
unless opts[:rows].respond_to? :to_i
raise "Columns must be an integer" unless opts[:columns].respond_to? :to_i
if @cards.size < opts[:columns].to_i
opts[:rows] = 1
else
opts[:rows] = (@cards.size / opts[:columns].to_i).ceil
end
end
opts
end

15
spec/input_helpers_spec.rb

@ -182,19 +182,30 @@ describe Squib::InputHelpers do
end
context '#rowify' do
before(:each) do
@default_opts = { rows: :infinite, columns: 5 }
end
it 'does nothing on an integer' do
opts = @deck.send(:rowify, {columns: 2, rows: 2})
opts = @deck.send(:rowify, @default_opts.merge({columns: 2, rows: 2}))
expect(opts).to eq({ columns: 2,
rows: 2
})
end
it 'computes properly on non-integer' do
opts = @deck.send(:rowify, {columns: 1, rows: :infinite})
opts = @deck.send(:rowify, @default_opts.merge({columns: 1, rows: :infinite}))
expect(opts).to eq({ columns: 1,
rows: 2
})
end
it 'computes properly on unspecified rows' do
opts = @deck.send(:rowify, @default_opts.merge({columns: 3}))
expect(opts).to eq({ columns: 3,
rows: 1
})
end
end
context '#faceify' do

Loading…
Cancel
Save