Sha256: 56a1177cbb947deedf5dc294d4163e4a882666bb53a409ab0ebbd71e72b368d7

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

RSpec.describe Riiif::ImagemagickCommandFactory do
  let(:path) { 'foo.tiff' }
  let(:info) { double(height: 100, width: 100, format: 'JPEG') }

  describe '.command' do
    subject { instance.command }
    let(:instance) { described_class.new(path, info, transformation) }

    let(:transformation) do
      IIIF::Image::Transformation.new(region: IIIF::Image::Region::Full.new,
                                      size: IIIF::Image::Size::Full.new,
                                      quality: 'quality',
                                      rotation: 15.2,
                                      format: format)
    end

    context "when it's a jpeg" do
      let(:format) { 'jpg' }
      it { is_expected.to match(/-quality 85/) }
    end

    context "when it's a tiff" do
      let(:format) { 'tif' }
      it { is_expected.not_to match(/-quality/) }
    end

    describe '#external_command' do
      let(:format) { 'jpg' }
      around do |example|
        orig = described_class.external_command
        described_class.external_command = 'gm convert'

        example.run

        described_class.external_command = orig
      end

      it { is_expected.to match(/\Agm convert/) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riiif-2.0.0 spec/services/riiif/imagemagick_command_factory_spec.rb