spec/writers/datacite_writer_spec.rb in bolognese-1.0.29 vs spec/writers/datacite_writer_spec.rb in bolognese-1.0.30

- old
+ new

@@ -27,11 +27,11 @@ expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Text") expect(datacite.dig("creators", "creator").count).to eq(7) expect(datacite.dig("creators", "creator")[2]).to eq("creatorName" => {"__content__"=>"Hernandez, Beatriz", "nameType"=>"Personal"}, "familyName" => "Hernandez", "givenName" => "Beatriz", - "nameIdentifier" => {"schemeURI"=>"http://orcid.org/", "nameIdentifierScheme"=>"ORCID", "__content__"=>"http://orcid.org/0000-0003-2043-4925"}) + "nameIdentifier" => {"nameIdentifierScheme"=>"ORCID", "__content__"=>"https://orcid.org/0000-0003-2043-4925"}) end it "with editor" do input = "https://doi.org/10.1371/journal.pone.0000030" subject = Bolognese::Metadata.new(input: input, from: "crossref") @@ -45,11 +45,11 @@ subject = Bolognese::Metadata.new(input: input, from: "bibtex") expect(subject.valid?).to be true datacite = Maremma.from_xml(subject.datacite).fetch("resource", {}) expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Text") expect(datacite.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth") - expect(datacite.dig("descriptions", "description").first).to eq("__content__"=>"eLife", "descriptionType"=>"SeriesInformation") + expect(datacite.dig("descriptions", "description").first).to eq("__content__"=>"eLife, 3", "descriptionType"=>"SeriesInformation") expect(datacite.dig("descriptions", "description", 1, "__content__")).to start_with("Among various advantages, their small size makes model organisms preferred subjects of investigation.") expect(datacite.dig("creators", "creator").count).to eq(5) expect(datacite.dig("creators", "creator").first).to eq("creatorName"=>{"__content__"=>"Sankar, Martial", "nameType"=>"Personal"}, "familyName"=>"Sankar", "givenName"=>"Martial") end @@ -73,41 +73,39 @@ expect(datacite.dig("titles", "title")).to eq("R Interface to the DataONE REST API") expect(datacite.dig("creators", "creator")).to eq([{"creatorName"=>{"__content__"=>"Jones, Matt", "nameType"=>"Personal"}, "givenName"=>"Matt", "familyName"=>"Jones", "nameIdentifier"=> - {"schemeURI"=>"http://orcid.org/", - "nameIdentifierScheme"=>"ORCID", - "__content__"=>"http://orcid.org/0000-0003-0077-4738"}}, + {"nameIdentifierScheme"=>"ORCID", + "__content__"=>"https://orcid.org/0000-0003-0077-4738"}}, {"creatorName"=>{"__content__"=>"Slaughter, Peter", "nameType"=>"Personal"}, "givenName"=>"Peter", "familyName"=>"Slaughter", "nameIdentifier"=> - {"schemeURI"=>"http://orcid.org/", - "nameIdentifierScheme"=>"ORCID", - "__content__"=>"http://orcid.org/0000-0002-2192-403X"}}, + {"nameIdentifierScheme"=>"ORCID", + "__content__"=>"https://orcid.org/0000-0002-2192-403X"}}, {"creatorName"=>{"__content__"=>"University Of California, Santa Barbara", "nameType"=>"Organizational"}}]) expect(datacite.fetch("version")).to eq("2.0.0") end it "maremma" do input = "https://github.com/datacite/maremma" subject = Bolognese::Metadata.new(input: input, from: "codemeta") expect(subject.valid?).to be true datacite = Maremma.from_xml(subject.datacite).fetch("resource", {}) expect(datacite.dig("titles", "title")).to eq("Maremma: a Ruby library for simplified network calls") - expect(datacite.dig("creators", "creator")).to eq("creatorName"=> {"__content__"=>"Fenner, Martin", "nameType"=>"Personal"}, "givenName"=>"Martin", "familyName"=>"Fenner", "nameIdentifier"=>{"schemeURI"=>"http://orcid.org/", "nameIdentifierScheme"=>"ORCID", "__content__"=>"http://orcid.org/0000-0003-0077-4738"}) + expect(datacite.dig("creators", "creator")).to eq("creatorName"=> {"__content__"=>"Fenner, Martin", "nameType"=>"Personal"}, "givenName"=>"Martin", "familyName"=>"Fenner", "nameIdentifier"=>{"__content__"=>"https://orcid.org/0000-0003-0077-4738", "nameIdentifierScheme"=>"ORCID"}) end it "Text pass-thru" do input = "https://doi.org/10.23640/07243.5153971" subject = Bolognese::Metadata.new(input: input, from: "datacite") expect(subject.valid?).to be true - expect(subject.identifier).to eq("https://doi.org/10.23640/07243.5153971") + expect(subject.identifiers).to eq([{"identifier"=>"https://doi.org/10.23640/07243.5153971", "identifierType"=>"DOI"}]) expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceType"=>"Paper", "resourceTypeGeneral"=>"Text", "ris"=>"RPRT", "schemaOrg"=>"ScholarlyArticle") expect(subject.creators.length).to eq(20) - expect(subject.creators.first).to eq("type"=>"Person", "familyName" => "Paglione", "givenName" => "Laura", "id" => "https://orcid.org/0000-0003-3188-6273", "name" => "Laura Paglione") + expect(subject.creators.first).to eq("nameType"=>"Personal", "familyName" => "Paglione", "givenName" => "Laura", "nameIdentifiers" => [{"nameIdentifier"=>"https://orcid.org/0000-0003-3188-6273", "nameIdentifierScheme"=>"ORCID"}], "name" => "Paglione, Laura") expect(subject.titles).to eq([{"title"=>"Recommendation of: ORCID Works Metadata Working Group"}]) expect(subject.rights_list).to eq([{"rightsUri"=>"https://creativecommons.org/publicdomain/zero/1.0", "rights"=>"CC-0"}]) expect(subject.dates).to eq([{"date"=>"2017-06-28", "dateType"=>"Created"}, {"date"=>"2017-06-28", "dateType"=>"Updated"}, {"date"=>"2017", "dateType"=>"Issued"}]) expect(subject.publication_year).to eq("2017") expect(subject.publisher).to eq("Figshare") @@ -118,14 +116,14 @@ it "Text pass-thru with doi in options" do input = "https://doi.org/10.23640/07243.5153971" subject = Bolognese::Metadata.new(input: input, from: "datacite", doi: "10.5072/07243.5153971") expect(subject.valid?).to be true - expect(subject.identifier).to eq("https://doi.org/10.5072/07243.5153971") + expect(subject.identifiers).to eq([{"identifier"=>"https://doi.org/10.5072/07243.5153971", "identifierType"=>"DOI"}]) expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceType"=>"Paper", "resourceTypeGeneral"=>"Text", "ris"=>"RPRT", "schemaOrg"=>"ScholarlyArticle") expect(subject.creators.length).to eq(20) - expect(subject.creators.first).to eq("type"=>"Person", "familyName" => "Paglione", "givenName" => "Laura", "id" => "https://orcid.org/0000-0003-3188-6273", "name" => "Laura Paglione") + expect(subject.creators.first).to eq("nameType" => "Personal", "familyName" => "Paglione", "givenName" => "Laura", "nameIdentifiers" => [{"nameIdentifier"=>"https://orcid.org/0000-0003-3188-6273", "nameIdentifierScheme"=>"ORCID"}], "name" => "Paglione, Laura") expect(subject.titles).to eq([{"title"=>"Recommendation of: ORCID Works Metadata Working Group"}]) expect(subject.rights_list).to eq([{"rightsUri"=>"https://creativecommons.org/publicdomain/zero/1.0", "rights"=>"CC-0"}]) expect(subject.dates).to eq([{"date"=>"2017-06-28", "dateType"=>"Created"}, {"date"=>"2017-06-28", "dateType"=>"Updated"}, {"date"=>"2017", "dateType"=>"Issued"}]) expect(subject.publication_year).to eq("2017") expect(subject.publisher).to eq("Figshare") @@ -136,16 +134,18 @@ it "Dataset in schema 4.0" do input = "https://doi.org/10.5061/DRYAD.8515" subject = Bolognese::Metadata.new(input: input, from: "datacite", regenerate: true) expect(subject.valid?).to be true - expect(subject.identifier).to eq("https://doi.org/10.5061/dryad.8515") expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"dataset", "resourceType"=>"DataPackage", "resourceTypeGeneral"=>"Dataset", "ris"=>"DATA", "schemaOrg"=>"Dataset") expect(subject.creators.length).to eq(8) - expect(subject.creators.first).to eq("type"=>"Person", "name"=>"Benjamin Ollomo", "givenName"=>"Benjamin", "familyName"=>"Ollomo") + expect(subject.creators.first).to eq("nameType" => "Personal", "name"=>"Ollomo, Benjamin", "givenName"=>"Benjamin", "familyName"=>"Ollomo") expect(subject.titles).to eq([{"title"=>"Data from: A new malaria agent in African hominids."}]) - expect(subject.alternate_identifiers).to eq([{"alternateIdentifier"=> "Ollomo B, Durand P, Prugnolle F, Douzery EJP, Arnathau C, Nkoghe D, Leroy E, Renaud F (2009) A new malaria agent in African hominids. PLoS Pathogens 5(5): e1000446.", "alternateIdentifierType"=>"citation"}]) + expect(subject.identifiers).to eq([{"identifier"=>"https://doi.org/10.5061/dryad.8515", "identifierType"=>"DOI"}, + {"identifier"=> + "Ollomo B, Durand P, Prugnolle F, Douzery EJP, Arnathau C, Nkoghe D, Leroy E, Renaud F (2009) A new malaria agent in African hominids. PLoS Pathogens 5(5): e1000446.", + "identifierType"=>"citation"}]) expect(subject.rights_list).to eq([{"rightsUri"=>"http://creativecommons.org/publicdomain/zero/1.0"}]) expect(subject.dates).to eq([{"date"=>"2011", "dateType"=>"Issued"}]) expect(subject.publication_year).to eq("2011") expect(subject.related_identifiers.length).to eq(6) expect(subject.related_identifiers.last).to eq("relatedIdentifier"=>"19478877", "relatedIdentifierType"=>"PMID", "relationType"=>"IsSupplementTo") @@ -169,11 +169,11 @@ it "DOI not found" do input = "https://doi.org/10.4124/05F6C379-DD68-4CDB-880D-33D3E9576D52/1" subject = Bolognese::Metadata.new(input: input, from: "datacite") expect(subject.valid?).to be false - expect(subject.identifier).to eq("https://doi.org/10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1") + expect(subject.identifiers).to eq([{"identifier"=>"https://doi.org/10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1", "identifierType"=>"DOI"}]) expect(subject.doi).to eq("10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1") expect(subject.agency).to eq("DataCite") expect(subject.state).to eq("not_found") datacite = Maremma.from_xml(subject.datacite).fetch("resource", {}) expect(datacite["identifier"]).to eq("identifierType"=>"DOI", "__content__"=>"10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1") @@ -214,10 +214,10 @@ input = "10.7554/eLife.01567" subject = Bolognese::Metadata.new(input: input, from: "crossref") subject.descriptions = { "description" => "This is an abstract." } expect(subject.valid?).to be true datacite = Maremma.from_xml(subject.datacite).fetch("resource", {}) - expect(datacite.dig("descriptions", "description")).to eq([{"__content__"=>"eLife", "descriptionType"=>"SeriesInformation"}, {"__content__"=>"This is an abstract.", "descriptionType"=>"Abstract"}]) + expect(datacite.dig("descriptions", "description")).to eq( [{"__content__"=>"eLife, 3", "descriptionType"=>"SeriesInformation"}, {"__content__"=>"This is an abstract.", "descriptionType"=>"Abstract"}]) end it "change description no input" do input = nil subject = Bolognese::Metadata.new(input: input, from: "datacite", doi: "10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")