Sha256: 764a80fdc63d464ff27fd65fa9e59e0c6bc6365f0bb8b151c09b60f95894de6b

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

module Hydra::Derivatives
  describe ExtractMetadata do
    let(:class_with_metadata_extraction) do
      Class.new do
        attr_reader :content, :mime_type, :uri

        def initialize(options = {})
          @content = options.fetch(:content, '')
          @mime_uype = options.fetch(:mime_type, nil)
          @uri = 'http://example.com/pid/123'
        end

        include Hydra::Derivatives::ExtractMetadata
        def has_content?; content.present?; end
      end
    end

    let(:initialization_options) { {content: 'abc', mime_type: 'text/plain'} }
    subject { class_with_metadata_extraction.new(initialization_options) }

    context '#extract_metadata' do
      context 'without content' do
        let(:initialization_options) { {content: '', mime_type: 'text/plain'} }
        it 'should be nil' do
          expect(subject.extract_metadata).to be_nil
        end
      end

      context 'with content', unless: ENV['TRAVIS'] == 'true' do
        let(:mime_type) { 'image/jpeg' }
        it 'should get some XML' do
          expect(subject.extract_metadata).to match "<identity format=\"Plain text\" mimetype=\"text/plain\""
        end
      end
    end

    context '#to_tempfile' do
      it 'has a method called to_tempfile' do
        expect { |b| subject.to_tempfile(&b) }.to yield_with_args(Tempfile)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hydra-derivatives-1.2.0 spec/lib/hydra/derivatives/extract_metadata_spec.rb
hydra-derivatives-1.1.0 spec/lib/hydra/derivatives/extract_metadata_spec.rb
hydra-derivatives-1.0.0 spec/lib/hydra/derivatives/extract_metadata_spec.rb
hydra-derivatives-1.0.0.rc1 spec/lib/hydra/derivatives/extract_metadata_spec.rb
hydra-derivatives-1.0.0.beta1 spec/lib/hydra/derivatives/extract_metadata_spec.rb