Sha256: a05f37d199fb457bd8ac0bbed0aa0ac7f622c43ec2ca4ae39e2a9b57e02cde18

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'
require 'hyrax/specs/shared_specs'

RSpec.describe Hyrax::DerivativeService do
  let(:valid_file_set) { FileSet.new }
  subject { described_class.new(file_set) }
  it_behaves_like "a Hyrax::DerivativeService"
  before do
    @cached_services = described_class.services
  end
  after do
    described_class.services = @cached_services
  end

  describe ".services=" do
    it "allows you to set the available services" do
      described_class.services = [Hyrax::FileSetDerivativesService, Hyrax::FileSetDerivativesService]
      expect(described_class.services).to eq [Hyrax::FileSetDerivativesService, Hyrax::FileSetDerivativesService]
    end
    it "defaults to an array" do
      expect(described_class.services).to eq [Hyrax::FileSetDerivativesService]
    end
  end

  describe ".for" do
    before do
      described_class.services = [Hyrax::FileSetDerivativesService]
    end
    context "when a FileSet matches the requirements of a service" do
      let(:file_set) do
        FileSet.new.tap do |f|
          allow(f).to receive(:mime_type).and_return(FileSet.image_mime_types.first)
        end
      end
      it "returns it" do
        expect(described_class.for(file_set)).to be_instance_of Hyrax::FileSetDerivativesService
      end
    end
    context "when a FileSet matches no services" do
      let(:file_set) { FileSet.new }
      it "returns a base DerivativeService" do
        expect(described_class.for(file_set)).to be_instance_of described_class
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyrax-1.1.1 spec/services/hyrax/derivative_service_spec.rb
hyrax-1.1.0 spec/services/hyrax/derivative_service_spec.rb
hyrax-1.0.5 spec/services/hyrax/derivative_service_spec.rb
hyrax-1.0.4 spec/services/hyrax/derivative_service_spec.rb
hyrax-1.0.3 spec/services/hyrax/derivative_service_spec.rb
hyrax-1.0.2 spec/services/hyrax/derivative_service_spec.rb
hyrax-1.0.1 spec/services/hyrax/derivative_service_spec.rb
hyrax-1.0.0.rc2 spec/services/hyrax/derivative_service_spec.rb
hyrax-1.0.0.rc1 spec/services/hyrax/derivative_service_spec.rb