Finished porting of save_png over to args classes

This commit is contained in:
Andy Meneely
2015-08-12 23:41:15 -04:00
parent 4aee48dada
commit f8a18cdbce
4 changed files with 64 additions and 16 deletions
+33 -3
View File
@@ -5,17 +5,47 @@ describe Squib::Args::SaveBatch do
subject(:save_batch) {Squib::Args::SaveBatch.new}
context 'dir' do
it 'is created if not exists (and warns)' do
opts = {dir: 'tocreate'}
Dir.chdir(output_dir) do
FileUtils.rm_rf('tocreate', secure: true)
expect(Squib.logger).to receive(:warn).with("Dir 'tocreate' does not exist, creating it.").once
save_batch.load! opts
expect(save_batch).to have_attributes({dir: 'tocreate'})
expect(save_batch).to have_attributes({dir: ['tocreate']})
expect(Dir.exists? 'tocreate').to be true
end
end
end
context 'rotate' do
it 'does nothing by default' do
opts = {}
save_batch.load! opts
expect(save_batch[0]).to have_attributes({rotate: false, angle: 0})
end
it 'rotates by pi/2 with true' do
opts = {rotate: true}
save_batch.load! opts
expect(save_batch[0]).to have_attributes({rotate: true, angle: Math::PI / 2})
end
it 'rotates by pi/2' do
opts = {rotate: :clockwise}
save_batch.load! opts
expect(save_batch[0]).to have_attributes({rotate: true, angle: Math::PI / 2})
end
it 'rotates by pi/2 with counterclockwise' do
opts = {rotate: :counterclockwise}
save_batch.load! opts
expect(save_batch[0]).to have_attributes({rotate: true, angle: 3 * Math::PI / 2})
end
it 'raises error on a number' do
opts = {rotate: 5.0}
expect { save_batch.load!(opts) }.to raise_error('invalid option to rotate: only [true, false, :clockwise, :counterclockwise]')
end
end
end