Convert save_sheet and save_pdf to args classes
This commit is contained in:
@@ -13,4 +13,46 @@ describe Squib::Args::Sheet do
|
||||
|
||||
end
|
||||
|
||||
context 'rows and colums' do
|
||||
subject(:sheet) { Squib::Args::Sheet.new({}, {}, 4) }
|
||||
|
||||
it 'does nothing on a perfect fit' do
|
||||
opts = { columns: 2, rows: 2 }
|
||||
sheet.load! opts
|
||||
expect(sheet).to have_attributes(columns: 2, rows: 2)
|
||||
end
|
||||
|
||||
it 'keeps both if specified' do
|
||||
opts = { columns: 1, rows: 1 }
|
||||
sheet.load! opts
|
||||
expect(sheet).to have_attributes(columns: 1, rows: 1)
|
||||
end
|
||||
|
||||
it 'computes properly on non-integer' do
|
||||
opts = {columns: 1, rows: :infinite}
|
||||
sheet.load! opts
|
||||
expect(sheet).to have_attributes( columns: 1, rows: 4 )
|
||||
end
|
||||
|
||||
it 'computes properly on unspecified rows' do
|
||||
opts = {columns: 1}
|
||||
sheet.load! opts
|
||||
expect(sheet).to have_attributes( columns: 1, rows: 4 )
|
||||
end
|
||||
|
||||
it 'computes properly on unspecified, too-big column' do
|
||||
opts = {}
|
||||
sheet.load! opts
|
||||
expect(sheet).to have_attributes( columns: 5, rows: 1 )
|
||||
end
|
||||
|
||||
it 'fails on a non-integer column' do
|
||||
opts = {columns: :infinite}
|
||||
expect { sheet.load!(opts) }.to raise_error('columns must be an integer')
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -26,8 +26,9 @@ describe Squib::Deck, '#save_pdf' do
|
||||
it 'make all the expected calls on a smoke test' do
|
||||
num_cards = 9
|
||||
deck = Squib::Deck.new(cards: 9, width: 825, height: 1125)
|
||||
expect(deck).to receive(:dirify) { |arg| arg } #don't create the dir
|
||||
expect(Squib.logger).to receive(:debug).at_least(:once)
|
||||
expect(Squib.logger).to receive(:warn).exactly(:once) #warn about making the dir
|
||||
expect(Dir).to receive(:mkdir) {} # don't actually make the dir
|
||||
expect(cxt).to receive(:scale).with(0.24, 0.24)
|
||||
|
||||
expect_card_place(75, 75)
|
||||
@@ -50,7 +51,8 @@ describe Squib::Deck, '#save_pdf' do
|
||||
args = { range: 2..4, file: 'foo.pdf', dir: '_out', margin: 75, gap: 5, trim: 37 }
|
||||
deck = Squib::Deck.new(cards: num_cards, width: 825, height: 1125)
|
||||
expect(Squib.logger).to receive(:debug).at_least(:once)
|
||||
expect(deck).to receive(:dirify) { |arg| arg } #don't create the dir
|
||||
expect(Squib.logger).to receive(:warn).exactly(:once) #warn about making the dir
|
||||
expect(Dir).to receive(:mkdir) {} # don't actually make the dir
|
||||
expect(cxt).to receive(:scale).with(0.24, 0.24)
|
||||
|
||||
expect_card_place(75, 75)
|
||||
|
||||
Reference in New Issue
Block a user