Sha256: 4c56a0c3381716c682e2aef00f00e757584e4a2d84de19150e3197335aacc7f6

Contents?: true

Size: 1.35 KB

Versions: 20

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true
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
    subject { described_class.new(metadata) }
    let(:metadata) { instance_double(GeoCombine::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
    subject { described_class.new(metadata) }
    let(:metadata) { instance_double(GeoCombine::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

20 entries across 20 versions & 1 rubygems

Version Path
geoblacklight-3.8.1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.8.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-4.0.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-4.0.0.pre.rc3 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.7.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-4.0.0.pre.rc2 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-4.0.0.pre.rc1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.6.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.5.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-4.0.0.pre.alpha.3 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-4.0.0.pre.alpha.2 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-4.0.0.pre.alpha.1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-4.0.0.pre.alpha spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.4.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.3.1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.3.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.2.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.1.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.0.1 spec/lib/geoblacklight/metadata_transformer/base_spec.rb
geoblacklight-3.0.0 spec/lib/geoblacklight/metadata_transformer/base_spec.rb