spec/writers/datacite_writer_spec.rb in bolognese-0.10.2 vs spec/writers/datacite_writer_spec.rb in bolognese-0.10.3
- old
+ new
@@ -173,12 +173,23 @@
expect(subject.valid?).to be false
expect(subject.identifier).to eq("https://doi.org/10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
expect(subject.doi).to eq("10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
expect(subject.service_provider).to eq("DataCite")
expect(subject.state).to eq("not_found")
- expect(subject.datacite).to be_nil
+ datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
+ expect(datacite["identifier"]).to eq("identifierType"=>"DOI", "__content__"=>"10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
+ expect(datacite["xmlns"]).to eq("http://datacite.org/schema/kernel-4")
end
+
+ it "no input" do
+ input = nil
+ subject = Bolognese::Metadata.new(input: input, from: "datacite", doi: "10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
+ expect(subject.valid?).to be false
+ datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
+ expect(datacite["identifier"]).to eq("identifierType"=>"DOI", "__content__"=>"10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
+ expect(datacite["xmlns"]).to eq("http://datacite.org/schema/kernel-4")
+ end
end
context "change metadata as datacite xml" do
it "with data citation" do
input = "10.7554/eLife.01567"
@@ -202,9 +213,18 @@
it "change description" do
input = "10.7554/eLife.01567"
subject = Bolognese::Metadata.new(input: input, from: "crossref")
subject.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("descriptionType"=>"Abstract", "__content__"=>"This is an 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")
+ subject.description = "This is an abstract."
+ expect(subject.valid?).to be false
datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
expect(datacite.dig("descriptions", "description")).to eq("descriptionType"=>"Abstract", "__content__"=>"This is an abstract.")
end
it "change license" do