Sha256: c547d8530e0dfe7ca34725c2ac9ec46e34e7d042845d1295fbebd8e2e8a7aa7d

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe Riiif::FileSystemFileResolver do
  let(:root) { File.expand_path(::File.join(::File.dirname(__FILE__), '../../..')) }
  let(:base_path) { ::File.join(root, 'spec/samples') }
  let(:resolver) { described_class.new(base_path: base_path) }

  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 base_path + '/world.jp2'
      end
    end
  end

  describe '#input_types' do
    subject { resolver.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

4 entries across 4 versions & 1 rubygems

Version Path
riiif-1.7.1 spec/models/riiif/file_system_file_resolver_spec.rb
riiif-2.0.0.beta1 spec/models/riiif/file_system_file_resolver_spec.rb
riiif-1.7.0 spec/models/riiif/file_system_file_resolver_spec.rb
riiif-1.6.0 spec/models/riiif/file_system_file_resolver_spec.rb