spec/models/riiif/image_spec.rb in riiif-2.0.0.beta2 vs spec/models/riiif/image_spec.rb in riiif-2.0.0
- old
+ new
@@ -28,22 +28,16 @@
end
it 'is able to override the file used for the Image' do
img = described_class.new('some_id', Riiif::File.new(filename))
expect(img.id).to eq 'some_id'
- expect(img.info).to eq Riiif::ImageInformation.new(800, 400)
+ expect(img.info).to eq Riiif::ImageInformation.new(width: 800, height: 400)
end
- describe 'without a format' do
- it 'raises an error' do
- expect { subject.render('size' => 'full') }.to raise_error ArgumentError
- end
- end
-
describe 'info' do
it 'returns the data' do
- expect(subject.info).to eq Riiif::ImageInformation.new(800, 400)
+ expect(subject.info).to eq Riiif::ImageInformation.new(width: 800, height: 400)
end
end
context 'using HTTPFileResolver' do
before do
@@ -57,11 +51,11 @@
end
describe 'get info' do
subject { described_class.new('Cave_26,_Ajanta') }
it 'is easy' do
- expect(subject.info).to eq Riiif::ImageInformation.new(600, 390)
+ expect(subject.info).to eq Riiif::ImageInformation.new(width: 600, height: 390)
end
end
context 'when the rendered image is in the cache' do
subject { described_class.new('Cave_26,_Ajanta') }
@@ -75,11 +69,11 @@
end
describe '#render' do
before do
allow(Riiif::CommandRunner).to receive(:execute)
- .with("identify -format %hx%w #{filename}[0]").and_return('131x175')
+ .with("identify -format '%h %w %m' #{filename}[0]").and_return('131 175 JPEG')
end
describe 'region' do
subject(:render) { image.render(region: region, format: 'png') }
@@ -106,11 +100,11 @@
context 'when specifing percent geometry' do
let(:region) { 'pct:10,10,80,70' }
it 'runs the correct imagemagick command' do
expect(Riiif::CommandRunner).to receive(:execute)
- .with("convert -crop 80%x70+18+13 -strip #{filename} png:-")
+ .with("convert -crop 80.0%x70.0+18+13 -strip #{filename} png:-")
render
end
end
context 'when specifing square geometry' do
@@ -125,11 +119,11 @@
context 'when the geometry is invalid' do
let(:region) { '150x75' }
it 'raises an error' do
- expect { render }.to raise_error Riiif::InvalidAttributeError
+ expect { render }.to raise_error IIIF::Image::InvalidAttributeError
end
end
end
describe 'resize' do
@@ -148,11 +142,11 @@
context 'when specifing percent size' do
let(:size) { 'pct:50' }
it 'runs the correct imagemagick command' do
expect(Riiif::CommandRunner).to receive(:execute)
- .with("convert -resize 50% -strip #{filename} png:-")
+ .with("convert -resize 50.0% -strip #{filename} png:-")
render
end
end
context 'when specifing float percent size' do
@@ -206,11 +200,11 @@
context 'when the geometry is invalid' do
let(:size) { '150x75' }
it 'raises an error' do
- expect { render }.to raise_error Riiif::InvalidAttributeError
+ expect { render }.to raise_error IIIF::Image::InvalidAttributeError
end
end
end
describe 'rotate' do
@@ -238,11 +232,11 @@
context 'with an invalid value' do
let(:rotation) { '150x' }
it 'raises an error for invalid angle' do
- expect { render }.to raise_error Riiif::InvalidAttributeError
+ expect { render }.to raise_error IIIF::Image::InvalidAttributeError
end
end
end
describe 'quality' do
@@ -290,10 +284,10 @@
context 'when an invalid quality is specified' do
let(:quality) { 'best' }
it 'raises an error' do
- expect { render }.to raise_error Riiif::InvalidAttributeError
+ expect { render }.to raise_error IIIF::Image::InvalidAttributeError
end
end
end
end
end