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-8.6.1 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.40.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.6.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.5.1 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.5.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.39.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.4.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.38.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/models/blacklight/document/dublin_core_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.3.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.2.2 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.2.1 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.2.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.37.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.36.2 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.36.1 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.36.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-7.35.0 spec/models/blacklight/document/dublin_core_spec.rb
blacklight-8.1.0 spec/models/blacklight/document/dublin_core_spec.rb