Sha256: 9d9a1859ad5be5efadcb4f752c10dae22733febcd776568ff2acef86355df245

Contents?: true

Size: 1.44 KB

Versions: 6

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Riiif::FileSystemFileResolver do
  let(:resolver) { described_class.new }

  describe '#find' do
    subject { resolver.find(id) }

    context "when the file isn't found" do
      let(:id) { '1234' }
      it 'raises an error' do
        expect { subject }.to raise_error Riiif::ImageNotFoundError
      end
    end

    context 'when a jpeg2000 file is found' do
      let(:id) { 'world' }
      it 'returns the jpeg2000 file' do
        expect(subject.path).to eq resolver.root + '/spec/samples/world.jp2'
      end
    end
  end

  describe '#input_types' do
    subject { described_class.new.send(:input_types) }

    it 'includes jp2 extension' do
      expect(subject).to include 'jp2'
    end

    it 'includes jpg extension' do
      expect(subject).to include 'jpg'
    end

    it 'includes tif extension' do
      expect(subject).to include 'tif'
    end

    it 'includes tiff extension' do
      expect(subject).to include 'tiff'
    end

    it 'includes png extension' do
      expect(subject).to include 'png'
    end
  end

  describe '#pattern' do
    subject { resolver.pattern(id) }

    context 'with dashes' do
      let(:id) { 'foo-bar-baz' }
      it 'accepts ids with dashes' do
        expect { subject }.not_to raise_error
      end
    end

    context 'with colons' do
      let(:id) { 'fo:baz' }
      it 'accepts ids with colons' do
        expect { subject }.not_to raise_error
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
riiif-1.5.1 spec/models/riiif/file_system_file_resolver_spec.rb
riiif-1.5.0 spec/models/riiif/file_system_file_resolver_spec.rb
riiif-1.4.4 spec/models/riiif/file_system_file_resolver_spec.rb
riiif-1.4.3 spec/models/riiif/file_system_file_resolver_spec.rb
riiif-1.4.2 spec/models/riiif/file_system_file_resolver_spec.rb
riiif-1.4.1 spec/models/riiif/file_system_file_resolver_spec.rb