spec/writers/datacite_writer_spec.rb in bolognese-0.9.36 vs spec/writers/datacite_writer_spec.rb in bolognese-0.9.37
- old
+ new
@@ -139,6 +139,38 @@
expect(datacite.dig("titles", "title")).to eq("Eating your own Dog Food")
expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").count).to eq(3)
expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"IsPartOf", "__content__"=>"https://doi.org/10.5438/0000-00ss")
end
end
+
+ context "change metadata as datacite xml" do
+ it "with data citation" do
+ input = "10.7554/eLife.01567"
+ subject = Bolognese::Metadata.new(input: input, from: "crossref")
+ subject.doi = "10.5061/DRYAD.8515"
+ subject.title = "Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"
+ subject.type = "Dataset"
+ datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
+ expect(datacite.dig("identifier", "__content__")).to eq("10.5061/DRYAD.8515")
+ expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Dataset")
+ expect(datacite.dig("titles", "title")).to eq("Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
+ expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").length).to eq(26)
+ expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"ISSN", "relationType"=>"IsPartOf", "__content__"=>"2050-084X")
+ expect(datacite.dig("relatedIdentifiers", "relatedIdentifier")[1]).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"References", "__content__"=>"https://doi.org/10.1038/nature02100")
+ expect(datacite.dig("rightsList")).to eq("rights"=>{"rightsURI"=>"http://creativecommons.org/licenses/by/3.0"})
+ expect(datacite.dig("fundingReferences", "fundingReference").count).to eq(4)
+ expect(datacite.dig("fundingReferences", "fundingReference").last).to eq("funderName"=>"University of Lausanne", "funderIdentifier"=>{"funderIdentifierType"=>"Crossref Funder ID", "__content__"=>"https://doi.org/10.13039/501100006390"})
+ end
+
+ it "validates against schema" do
+ input = "10.7554/eLife.01567"
+ subject = Bolognese::Metadata.new(input: input, from: "crossref")
+ subject.doi = "123"
+ subject.title = "Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"
+ subject.type = "Dataset"
+ expect(subject.doi).to eq("123")
+ expect(subject.valid?).to be false
+ expect(subject.errors.first).to start_with("Element '{http://datacite.org/schema/kernel-4}identifier'")
+ datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
+ end
+ end
end