partway through the conversion

This commit is contained in:
Andy Meneely
2020-03-16 16:38:13 -04:00
parent 70b3c0b136
commit 77a694f797
22 changed files with 553 additions and 461 deletions
+6 -5
View File
@@ -107,18 +107,19 @@ describe Squib::Args::Box do
end
context 'validation' do
let(:deck) { OpenStruct.new(width: 123, height: 456, size: 1) }
it 'replaces with deck width and height' do
args = { width: :deck, height: :deck }
deck = OpenStruct.new(width: 123, height: 456)
box = Squib::Args::Box.new(deck)
box.load!(args, expand_by: 1)
box = Squib::Args::Box.new
box.extract! args, deck
expect(box).to have_attributes(width: [123], height: [456])
end
it 'has radius override x_radius and y_radius' do
args = { x_radius: 1, y_radius: 2, radius: 3 }
box.load!(args, expand_by: 2)
expect(box).to have_attributes(x_radius: [3, 3], y_radius: [3, 3])
box.extract! args, deck
expect(box).to have_attributes(x_radius: [3], y_radius: [3])
end
end
+1 -1
View File
@@ -2,7 +2,7 @@ require 'spec_helper'
require 'squib/args/scale_box'
describe Squib::Args::ScaleBox do
subject(:box) { Squib::Args::ScaleBox.new({}) }
subject(:box) { Squib::Args::ScaleBox.new }
context 'unit conversion' do
it 'converts units on all args' do
+13 -11
View File
@@ -2,58 +2,60 @@ require 'spec_helper'
require 'squib/args/sheet'
describe Squib::Args::Sheet do
let(:deck) { OpenStruct.new(size: 4, custom_colors: {}) }
context 'dsl overrides' do
subject(:sheet) { Squib::Args::Sheet.new({}, { file: 'foo' }) }
subject(:sheet) { Squib::Args::Sheet.new({ file: 'foo' }) }
it 'works when specified' do
sheet.load!({}) # go right to defaults
opts = {}
sheet.extract! opts, deck # go right to defaults
expect(sheet.file).to eq('foo') # dsl method default override
end
end
context 'rows and colums' do
subject(:sheet) { Squib::Args::Sheet.new({}, {}, 4) }
subject(:sheet) { Squib::Args::Sheet.new }
it 'does nothing on a perfect fit' do
opts = { columns: 2, rows: 2 }
sheet.load! opts
sheet.extract! opts, deck
expect(sheet).to have_attributes(columns: 2, rows: 2)
end
it 'keeps both if specified' do
opts = { columns: 1, rows: 1 }
sheet.load! opts
sheet.extract! opts, deck
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
sheet.extract! opts, deck
expect(sheet).to have_attributes(columns: 1, rows: 4)
end
it 'computes properly on unspecified rows' do
opts = { columns: 1 }
sheet.load! opts
sheet.extract! opts, deck
expect(sheet).to have_attributes(columns: 1, rows: 4)
end
it 'computes properly on unspecified, too-big column' do
opts = {}
sheet.load! opts
sheet.extract! opts, deck
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')
expect { sheet.extract!(opts, deck) }.to raise_error('columns must be an integer')
end
end
context 'crop marks' do
subject(:sheet) { Squib::Args::Sheet.new({}, {}, 4) }
subject(:sheet) { Squib::Args::Sheet.new }
it 'computes crop marks properly' do
opts = {
@@ -65,7 +67,7 @@ describe Squib::Args::Sheet do
crop_margin_right: 40,
crop_margin_bottom: 50,
}
expect(sheet.load!(opts).crop_coords(3,4, 300, 400)).to eq(
expect(sheet.extract!(opts, deck).crop_coords(3,4, 300, 400)).to eq(
[ {:x1=>43, :y1=>0, :x2=>43, :y2=>74},
{:x1=>253, :y1=>0, :x2=>253, :y2=>74},
{:x1=>43, :y1=>1100, :x2=>43, :y2=>1026},
+1
View File
@@ -1,5 +1,6 @@
require 'spec_helper'
require 'squib/args/box'
require 'squib/args/svg_special'
describe Squib::Args::SvgSpecial do
subject(:svgargs) { Squib::Args::SvgSpecial.new }
+5 -4
View File
@@ -8,15 +8,16 @@ describe Squib::Args::Box do
context 'validation' do
it 'replaces with deck width and height' do
args = { crop_width: :deck, crop_height: :deck }
deck = OpenStruct.new(width: 123, height: 456)
trans = Squib::Args::Transform.new(deck)
trans.load!(args, expand_by: 1)
deck = OpenStruct.new(width: 123, height: 456, size: 1)
trans = Squib::Args::Transform.new
trans.extract! args, deck
expect(trans).to have_attributes(crop_width: [123], crop_height: [456])
end
it 'has radius override x_radius and y_radius' do
args = { crop_corner_x_radius: 1, crop_corner_y_radius: 2, crop_corner_radius: 3 }
trans.load!(args, expand_by: 2)
deck = OpenStruct.new(width: 123, height: 456, size: 2)
trans.extract! args, deck
expect(trans).to have_attributes(crop_corner_x_radius: [3, 3], crop_corner_y_radius: [3, 3])
end