spec/codemeta_spec.rb in bolognese-0.8.5 vs spec/codemeta_spec.rb in bolognese-0.8.7

- old
+ new

@@ -96,18 +96,18 @@ it "rdataone" do string = IO.read(fixture_path + 'codemeta.json') subject = Bolognese::Codemeta.new(string: string) datacite = Maremma.from_xml(subject.datacite).fetch("resource", {}) expect(datacite.dig("titles", "title")).to eq("R Interface to the DataONE REST API") - expect(datacite.dig("creators", "creator")).to eq([{"creatorName"=>"Matt Jones", + expect(datacite.dig("creators", "creator")).to eq([{"creatorName"=>"Jones, Matt", "givenName"=>"Matt", "familyName"=>"Jones", "nameIdentifier"=> {"schemeURI"=>"http://orcid.org/", "nameIdentifierScheme"=>"ORCID", "__content__"=>"http://orcid.org/0000-0003-0077-4738"}}, - {"creatorName"=>"Peter Slaughter", + {"creatorName"=>"Slaughter, Peter", "givenName"=>"Peter", "familyName"=>"Slaughter", "nameIdentifier"=> {"schemeURI"=>"http://orcid.org/", "nameIdentifierScheme"=>"ORCID", @@ -117,11 +117,11 @@ end it "maremma" do 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"=>"Martin Fenner", "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"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner", "nameIdentifier"=>{"schemeURI"=>"http://orcid.org/", "nameIdentifierScheme"=>"ORCID", "__content__"=>"http://orcid.org/0000-0003-0077-4738"}) end end context "get metadata as schema.org JSON" do it "rdataone" do @@ -164,8 +164,38 @@ expect(bibtex[:title]).to eq("Maremma: a Ruby library for simplified network calls") expect(bibtex[:author]).to eq("Fenner, Martin") expect(bibtex[:publisher]).to eq("DataCite") expect(bibtex[:keywords]).to eq("faraday, excon, net/http") expect(bibtex[:year]).to eq("2017") + end + end + + context "get metadata as citeproc" do + it "maremma" do + json = JSON.parse(subject.citeproc) + expect(json["type"]).to eq("computer_program") + expect(json["id"]).to eq("https://doi.org/10.5438/qeg0-3gm3") + expect(json["DOI"]).to eq("10.5438/qeg0-3gm3") + expect(json["title"]).to eq("Maremma: a Ruby library for simplified network calls") + expect(json["author"]).to eq("family" => "Fenner", "given" => "Martin") + expect(json["publisher"]).to eq("DataCite") + expect(json["issued"]).to eq("date-parts" => [[2017, 2, 24]]) + end + end + + context "get metadata as ris" do + it "maremma" do + ris = subject.ris.split("\r\n") + expect(ris[0]).to eq("TY - COMP") + expect(ris[1]).to eq("T1 - Maremma: a Ruby library for simplified network calls") + expect(ris[2]).to eq("T2 - DataCite") + expect(ris[3]).to eq("AU - Fenner, Martin") + expect(ris[4]).to eq("DO - 10.5438/qeg0-3gm3") + expect(ris[5]).to eq("UR - https://github.com/datacite/maremma") + expect(ris[6]).to eq("AB - Ruby utility library for network requests. Based on Faraday and Excon, provides a wrapper for XML/JSON parsing and error handling. All successful responses are returned as hash with key data, all errors in a JSONAPI-friendly hash with key errors.") + expect(ris[7]).to eq("KW - faraday") + expect(ris[10]).to eq("PY - 2017") + expect(ris[11]).to eq("PB - DataCite") + expect(ris[12]).to eq("ER - ") end end end