spec/crossref_spec.rb in bolognese-0.2.2 vs spec/crossref_spec.rb in bolognese-0.3
- old
+ new
@@ -1,14 +1,16 @@
require 'spec_helper'
describe Bolognese::Crossref, vcr: true do
- context "get metadata" do
- let(:id) { "https://doi.org/10.1371/journal.pone.0000030" }
+ let(:id) { "10.7554/eLife.01567" }
- subject { Bolognese::Crossref.new(id) }
+ subject { Bolognese::Crossref.new(id) }
+ context "get metadata" do
it "journal article" do
+ id = "https://doi.org/10.1371/journal.pone.0000030"
+ subject = Bolognese::Crossref.new(id)
expect(subject.id).to eq(id)
expect(subject.type).to eq("ScholarlyArticle")
expect(subject.additional_type).to eq("JournalArticle")
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Markus", "familyName"=>"Ralser"},
{"@type"=>"Person", "givenName"=>"Gino", "familyName"=>"Heeren"},
@@ -41,12 +43,10 @@
expect(subject.is_part_of).to be_nil
expect(subject.provider).to eq("@type"=>"Organization", "name"=>"Crossref")
end
it "DOI with data citation" do
- id = "10.7554/eLife.01567"
- subject = Bolognese::Crossref.new(id)
expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
expect(subject.type).to eq("ScholarlyArticle")
expect(subject.additional_type).to eq("JournalArticle")
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Martial", "familyName"=>"Sankar"},
{"@type"=>"Person", "givenName"=>"Kaisa", "familyName"=>"Nieminen"},
@@ -102,12 +102,20 @@
expect(subject.is_part_of).to eq("@type"=>"Periodical", "name"=>"European Journal of Pharmacology", "issn"=>"00142999")
expect(subject.provider).to eq("@type"=>"Organization", "name"=>"Crossref")
end
it "not found error" do
- id = "https://doi.org/10.1371/journal.pone.0000030x"
+ id = "https://doi.org/10.7554/elife.01567x"
subject = Bolognese::Crossref.new(id)
expect(subject.id).to eq(id)
expect(subject.exists?).to be false
+ end
+ end
+
+ context "get metadata as datacite xml" do
+ it "DOI with data citation" do
+ expect(subject.validation_errors).to be_empty
+ datacite = Maremma.from_xml(subject.as_datacite).fetch("resource", {})
+ expect(datacite.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
end
end
end