spec/writers/datacite_writer_spec.rb in bolognese-1.0.2 vs spec/writers/datacite_writer_spec.rb in bolognese-1.0.3

- old
+ new

@@ -101,18 +101,17 @@ 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.type).to eq("ScholarlyArticle") - expect(subject.additional_type).to eq("Paper") - expect(subject.resource_type_general).to eq("Text") + expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resource_type"=>"Paper", "resource_type_general"=>"Text", "ris"=>"RPRT", "type"=>"ScholarlyArticle") expect(subject.creator.length).to eq(20) expect(subject.creator.first).to eq("type"=>"Person", "familyName" => "Paglione", "givenName" => "Laura", "id" => "https://orcid.org/0000-0003-3188-6273", "name" => "Laura Paglione") expect(subject.title).to eq("Recommendation of: ORCID Works Metadata Working Group") expect(subject.rights).to eq("id"=>"https://creativecommons.org/publicdomain/zero/1.0", "name"=>"CC-0") - expect(subject.date_published).to eq("2017") + expect(subject.dates).to eq([{"date"=>"2017-06-28", "date_type"=>"Created"}, {"date"=>"2017-06-28", "date_type"=>"Updated"}, {"date"=>"2017", "date_type"=>"Issued"}]) + expect(subject.publication_year).to eq("2017") expect(subject.publisher).to eq("Figshare") expect(subject.service_provider).to eq("DataCite") expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3") expect(subject.datacite).to end_with("</resource>") end @@ -120,18 +119,17 @@ 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.type).to eq("ScholarlyArticle") - expect(subject.additional_type).to eq("Paper") - expect(subject.resource_type_general).to eq("Text") + expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resource_type"=>"Paper", "resource_type_general"=>"Text", "ris"=>"RPRT", "type"=>"ScholarlyArticle") expect(subject.creator.length).to eq(20) expect(subject.creator.first).to eq("type"=>"Person", "familyName" => "Paglione", "givenName" => "Laura", "id" => "https://orcid.org/0000-0003-3188-6273", "name" => "Laura Paglione") expect(subject.title).to eq("Recommendation of: ORCID Works Metadata Working Group") expect(subject.rights).to eq("id"=>"https://creativecommons.org/publicdomain/zero/1.0", "name"=>"CC-0") - expect(subject.date_published).to eq("2017") + expect(subject.dates).to eq([{"date"=>"2017-06-28", "date_type"=>"Created"}, {"date"=>"2017-06-28", "date_type"=>"Updated"}, {"date"=>"2017", "date_type"=>"Issued"}]) + expect(subject.publication_year).to eq("2017") expect(subject.publisher).to eq("Figshare") expect(subject.service_provider).to eq("DataCite") expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3") expect(subject.datacite).to end_with("</resource>") end @@ -139,19 +137,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.type).to eq("Dataset") - expect(subject.additional_type).to eq("DataPackage") - expect(subject.resource_type_general).to eq("Dataset") + expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"dataset", "resource_type"=>"DataPackage", "resource_type_general"=>"Dataset", "ris"=>"DATA", "type"=>"Dataset") expect(subject.creator.length).to eq(8) expect(subject.creator.first).to eq("type"=>"Person", "name"=>"Benjamin Ollomo", "givenName"=>"Benjamin", "familyName"=>"Ollomo") expect(subject.title).to eq("Data from: A new malaria agent in African hominids.") expect(subject.alternate_identifiers).to eq("type"=>"citation", "name"=>"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.") expect(subject.rights).to eq("id"=>"http://creativecommons.org/publicdomain/zero/1.0") - expect(subject.date_published).to eq("2011") + expect(subject.dates).to eq([{"date"=>"2011", "date_type"=>"Issued"}]) + expect(subject.publication_year).to eq("2011") expect(subject.related_identifiers.length).to eq(6) expect(subject.related_identifiers.last).to eq("id"=>"19478877", "related_identifier_type"=>"PMID", "relation_type"=>"IsSupplementTo") expect(subject.publisher).to eq("Dryad Digital Repository") expect(subject.service_provider).to eq("DataCite") expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4") @@ -197,11 +194,11 @@ 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.resource_type_general = "Dataset" + subject.types = { "type" => "Dataset", "resource_type_general" => "Dataset" } expect(subject.valid?).to be true 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") @@ -235,14 +232,14 @@ input = nil subject = Bolognese::Metadata.new(input: input, doi: "10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1") subject.creator = [{"creatorName"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner"}] subject.title = "Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth" subject.publisher = "Dryad" - subject.resource_type_general = "Dataset" - subject.additional_type = "DataPackage" - subject.date_published = "2011" + subject.types = "Dataset" + subject.publication_year = "2011" subject.state = "findable" + subject.types = { "type" => "Dataset", "resource_type_general" => "Dataset" } expect(subject.exists?).to be true datacite = Maremma.from_xml(subject.datacite).fetch("resource", {}) expect(datacite.dig("identifier", "__content__")).to eq("10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1") 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") @@ -290,10 +287,10 @@ 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" + subject.types = "Dataset" expect(subject.doi).to eq("123") expect(subject.valid?).to be false expect(subject.errors.first).to start_with("3:0: ERROR: Element '{http://datacite.org/schema/kernel-4}identifier'") datacite = Maremma.from_xml(subject.datacite).fetch("resource", {}) end