Sha256: 663d9c6fa49e06bee943efc751cfdce85c2672a422d9c10718002d2a79220947
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
require 'spec_helper' module Datacite module Mapping module Nonvalidating describe Identifier do describe '#new' do it 'accepts a nil value' do id = Identifier.new(value: nil) expect(id.identifier_type).to eq('DOI') end it 'accepts an invalid value' do id = Identifier.new(value: 'elvis') expect(id.value).to eq('elvis') end end describe '#load_from_xml' do it 'parses a valid identifier' do xml_text = "<identifier identifierType='DOI'>10.14749/1407399498</identifier>" id = Identifier.parse_xml(xml_text, mapping: :nonvalidating) expect(id.identifier_type).to eq('DOI') expect(id.value).to eq('10.14749/1407399498') end it 'parses an identifier with a missing value' do xml_text = "<identifier identifierType='DOI'/>" id = Identifier.parse_xml(xml_text, mapping: :nonvalidating) expect(id.identifier_type).to eq('DOI') expect(id.value).to be_nil end end describe '#save_to_xml' do it 'writes a valid identifier' do xml_text = "<identifier identifierType='DOI'>10.14749/1407399498</identifier>" id = Identifier.parse_xml(xml_text, mapping: :nonvalidating) expect(id.write_xml(mapping: :nonvalidating)).to be_xml(xml_text) end it 'writes an identifier with a missing value' do xml_text = "<identifier identifierType='DOI'/>" id = Identifier.parse_xml(xml_text, mapping: :nonvalidating) expect(id.write_xml(mapping: :nonvalidating)).to be_xml(xml_text) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datacite-mapping-0.1.17.2 | spec/unit/datacite/mapping/nonvalidating/identifier_spec.rb |