Sha256: d6d3ff87355bbefadfaab07798d1b7434d2ada4f1a9140fc26f96f5b57363b88

Contents?: true

Size: 1.81 KB

Versions: 4

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe 'OIA-PMH GetRecord Request' do
  let(:xml) { Nokogiri::XML(response.body) }
  let(:namespaces) do
    {
      dc: 'http://purl.org/dc/elements/1.1/',
      xmlns: 'http://www.openarchives.org/OAI/2.0/',
      oai_dc: 'http://www.openarchives.org/OAI/2.0/oai_dc/'
    }
  end

  before do
    get '/catalog/oai?verb=GetRecord&identifier=oai:test:2007020969&metadataPrefix=oai_dc'
  end

  it 'contains identifier' do
    expect(xml.at_xpath('//xmlns:GetRecord/xmlns:record/xmlns:header/xmlns:identifier').text).to eql 'oai:test:2007020969'
  end

  it 'contains datestamp' do
    expect(xml.at_xpath('//xmlns:GetRecord/xmlns:record/xmlns:header/xmlns:datestamp').text).to eql '2014-02-03T18:42:53Z'
  end

  it 'contains sets' do
    expect(xml.at_xpath('//xmlns:GetRecord/xmlns:record/xmlns:header/xmlns:setSpec').text).to eql 'language:English'
  end

  it 'contains creator' do
    expect(xml.at_xpath('//xmlns:metadata/oai_dc:dc/dc:creator', namespaces).text).to eql 'Hearth, Amy Hill, 1958-'
  end

  it 'contains date' do
    expect(xml.at_xpath('//xmlns:metadata/oai_dc:dc/dc:date', namespaces).text).to eql '2008'
  end

  it 'contains subjects' do
    nodes = xml.xpath('//xmlns:metadata/oai_dc:dc/dc:subject', namespaces)
    expect(nodes.count).to be 4
    expect(nodes.map(&:text)).to match_array ['Strong Medicine, 1922-', 'Delaware women', 'Indian women shamans', 'Delaware Indians']
  end

  it 'contains title' do
    expect(xml.at_xpath('//xmlns:metadata/oai_dc:dc/dc:title', namespaces).text).to eql '"Strong Medicine speaks"'
  end

  it 'contains language' do
    expect(xml.at_xpath('//xmlns:metadata/oai_dc:dc/dc:language', namespaces).text).to eql 'English'
  end

  it 'contains format' do
    expect(xml.at_xpath('//xmlns:metadata/oai_dc:dc/dc:format', namespaces).text).to eql 'Book'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blacklight_oai_provider-6.0.0.pre1 spec/requests/get_record_spec.rb
blacklight_oai_provider-5.1.0 spec/requests/get_record_spec.rb
blacklight_oai_provider-5.0.0 spec/requests/get_record_spec.rb
blacklight_oai_provider-5.0.0.pre1 spec/requests/get_record_spec.rb