Sha256: 25f6d31c419fdb8a841090450a941d9308c10326fba1928bbf5a606e60ba0790

Contents?: true

Size: 1.34 KB

Versions: 95

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

RSpec.describe "Blacklight::Document::DublinCore" do
  before(:all) do
    @mock_class = Class.new do
      include Blacklight::Document
    end
    @mock_class.use_extension(Blacklight::Document::DublinCore)
    @mock_class.field_semantics.merge!(
      title: :title_tsim,
      non_dc_title: :title_tsim
    )
  end

  it "registers all its export formats" do
    document = @mock_class.new
    expect(document.export_formats.keys).to include :oai_dc_xml, :dc_xml, :xml
  end

  it "exports oai_dc with the proper namespaces" do
    document = @mock_class.new
    expect(document.export_as_oai_dc_xml).to match 'xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"'
  end

  it "includes 'dc:'-prefixed semantic fields" do
    data = { 'id' => '123456', 'title_tsim' => ['654321'] }
    document = @mock_class.new(data)
    expect(document.export_as_oai_dc_xml).to match  'xmlns:dc="http://purl.org/dc/elements/1.1/"'
    expect(document.export_as_oai_dc_xml).to match  '<dc:title>654321</dc:title>'
  end

  it "works with multi-value fields" do
    data = { 'id' => '123456', 'title_tsim' => %w[654321 987] }
    document = @mock_class.new(data)
    expect(document.export_as_oai_dc_xml).to match '<dc:title>654321</dc:title>'
    expect(document.export_as_oai_dc_xml).to match '<dc:title>987</dc:title></oai_dc:dc>'
  end
end

Version data entries

95 entries across 94 versions & 2 rubygems

Version Path
blacklight-7.34.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.1 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0.beta8 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0.beta7 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0.beta6 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0.beta5 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.33.1 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0.beta4 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0.beta3 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0.beta2 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.0.0.beta1 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.33.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.32.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.31.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.30.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.29.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.28.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.27.1 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.27.0 spec/models/blacklight/document/dublin_core_spec.rb