Sha256: d65ea28f2ce0433949d9a6f9a2f9993a89602608158093efd8d4c2f4b2aac7a8

Contents?: true

Size: 1.21 KB

Versions: 34

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe Krikri::XmlParser do
  subject { Krikri::XmlParser.new(record) }
  let(:record) { build(:oai_dc_record) }

  it_behaves_like 'a parser'

  context 'with a root path' do
    subject { Krikri::XmlParser.new(record, '//oai_dc:dc') }

    it_behaves_like 'a parser'
  end

  context 'with no root path' do
    subject { Krikri::XmlParser.new(record, '//oai_dc:fake_root') }

    it 'raises an error' do
      expect { subject }.to raise_error described_class::EmptyRootNodeError
    end
  end
end

describe Krikri::XmlParser::Value do
  subject { Krikri::XmlParser.new(record).root }
  let(:record) { build(:oai_dc_record) }

  it_behaves_like 'a parser value'
  it_behaves_like 'a parser value that has attributes'

  context 'with a root path' do
    subject { Krikri::XmlParser.new(record, '//oai_dc:dc').root }

    it 'allows boolean "or" with "|" in the field name' do
      expect(subject['dc:notdefined|dc:type'].values).to eq ["model"]
    end

    it 'returns the value from the first defined name, given a "|"' do
      # "dc:type" comes last in the document, but comes first in the "|"
      # expression:
      expect(subject['dc:type|dc:title'].values)
        .to eq ["model"]
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
krikri-0.15.2 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.15.1 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.15.0 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.14.0 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.13.2 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.13.1 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.13.0 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.12.4 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.12.3 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.12.1 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.12.0 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.12.0.pre.rc.1 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.11.2 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.11.1 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.11.0 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.10.1 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.10.0 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.9.0 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.8.9 spec/lib/krikri/parsers/xml_parser_spec.rb
krikri-0.8.8 spec/lib/krikri/parsers/xml_parser_spec.rb