Sha256: a2472a963e7dd35b687a7281912ecf47cd6f356f0a15e4dacabefcb413acb235

Contents?: true

Size: 1.32 KB

Versions: 14

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe Geoblacklight::MetadataTransformer::Base do
  describe '.new' do
    it 'raises an error for empty XML' do
      expect { described_class.new(nil) }.to raise_error Geoblacklight::MetadataTransformer::EmptyMetadataError
    end
  end

  context 'with metadata types without XSL Stylesheets' do
    let(:metadata) { instance_double(GeoCombine::Metadata) }
    subject { described_class.new(metadata) }
    describe '#transform' do
      before do
        allow(metadata).to receive(:to_html).and_raise(NoMethodError, 'undefined method `to_html\'')
      end
      it 'raises a transform error' do
        expect { subject.transform }.to raise_error Geoblacklight::MetadataTransformer::TransformError, /undefined method `to_html'/
      end
    end
  end

  context 'with metadata types with XSL Stylesheets but invalid HTML' do
    let(:metadata) { instance_double(GeoCombine::Metadata) }
    subject { described_class.new(metadata) }
    describe '#transform' do
      before do
        allow(metadata).to receive(:to_html).and_return('<invalid-html></invalid-html>')
      end
      it 'raises a transform error' do
        expect { subject.transform }.to raise_error Geoblacklight::MetadataTransformer::TransformError, 'Failed to extract the <body> child elements from the transformed metadata'
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
geoblacklight-2.4.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-2.3.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-2.2.1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-2.2.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-2.1.2 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-2.1.1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-2.1.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-2.0.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-1.9.1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-1.9.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-1.8.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-1.7.1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-1.7.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-1.6.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb