diff --git a/spec/api/api_spec.rb b/spec/api/api_spec.rb index e64bb68..e3a6836 100644 --- a/spec/api/api_spec.rb +++ b/spec/api/api_spec.rb @@ -183,7 +183,7 @@ # expect(last_response.status).to eq(200) # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) - # expect(rdfxml.dig("BlogPosting", "rdf:about")).to eq("https://doi.org/10.14454/cne7-ar31") + # expect(rdfxml.dig("BlogPosting", "rdf:about")).to eq("https://doi.org/10.14454/cne7-ar31") # end # it "link" do @@ -191,7 +191,7 @@ # expect(last_response.status).to eq(200) # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) - # expect(rdfxml.dig("BlogPosting", "rdf:about")).to eq("https://doi.org/10.14454/cne7-ar31") + # expect(rdfxml.dig("BlogPosting", "rdf:about")).to eq("https://doi.org/10.14454/cne7-ar31") # end # end @@ -309,321 +309,558 @@ end end -describe 'content negotiation crossref', type: :api, vcr: true do - let(:doi) { "10.7554/elife.01567" } +# describe 'content negotiation crossref', type: :api, vcr: true do +# let(:doi) { "10.7554/elife.01567" } - context "application/vnd.crossref.unixref+xml" do - let(:doi) { "10.7554/elife.01567" } +# context "application/vnd.crossref.unixref+xml" do +# let(:doi) { "10.7554/elife.01567" } - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.crossref.unixref+xml" } - - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).dig("crossref_result", "query_result", "body", "query", "doi_record") - expect(response.dig("crossref", "journal", "journal_article", "doi_data", "doi")).to eq("10.7554/eLife.01567") - end +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.crossref.unixref+xml" } - it "link" do - get "/application/vnd.crossref.unixref+xml/#{doi}" +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).dig("crossref_result", "query_result", "body", "query", "doi_record") +# expect(response.dig("crossref", "journal", "journal_article", "doi_data", "doi")).to eq("10.7554/eLife.01567") +# end - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).dig("crossref_result", "query_result", "body", "query", "doi_record") - expect(response.dig("crossref", "journal", "journal_article", "doi_data", "doi")).to eq("10.7554/eLife.01567") - end - end +# it "link" do +# get "/application/vnd.crossref.unixref+xml/#{doi}" - context "application/vnd.jats+xml" do - let(:doi) { "10.7554/elife.01567" } +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).dig("crossref_result", "query_result", "body", "query", "doi_record") +# expect(response.dig("crossref", "journal", "journal_article", "doi_data", "doi")).to eq("10.7554/eLife.01567") +# end +# end - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.jats+xml" } +# context "application/vnd.jats+xml" do +# let(:doi) { "10.7554/elife.01567" } - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).dig("element_citation") - expect(response.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.7554/elife.01567") - end +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.jats+xml" } - it "link" do - get "/application/vnd.jats+xml/#{doi}" +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).dig("element_citation") +# expect(response.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.7554/elife.01567") +# end - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).dig("element_citation") - expect(response.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.7554/elife.01567") - end - end +# it "link" do +# get "/application/vnd.jats+xml/#{doi}" - context "application/vnd.datacite.datacite+xml" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+xml" } +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).dig("element_citation") +# expect(response.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.7554/elife.01567") +# end +# end - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) - expect(response.dig("publisher")).to eq("eLife Sciences Publications, Ltd") - expect(response.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth") - end +# context "application/vnd.datacite.datacite+xml" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+xml" } - it "link" do - get "/application/vnd.datacite.datacite+xml/#{doi}" +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) +# expect(response.dig("publisher")).to eq("eLife Sciences Publications, Ltd") +# expect(response.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth") +# end - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) - expect(response.dig("publisher")).to eq("eLife Sciences Publications, Ltd") - expect(response.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth") - end +# it "link" do +# get "/application/vnd.datacite.datacite+xml/#{doi}" - it "not found" do - doi = "10.15146/R34015" - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+xml" } +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) +# expect(response.dig("publisher")).to eq("eLife Sciences Publications, Ltd") +# expect(response.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth") +# end - expect(last_response.status).to eq(404) - expect(last_response.body).to eq("The resource you are looking for doesn't exist.") - end - end +# it "not found" do +# doi = "10.15146/R34015" +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+xml" } - context "application/vnd.datacite.datacite+json" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+json" } +# expect(last_response.status).to eq(404) +# expect(last_response.body).to eq("The resource you are looking for doesn't exist.") +# end +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["id"]).to eq("https://doi.org/10.7554/elife.01567") - end +# context "application/vnd.datacite.datacite+json" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+json" } - it "link" do - get "/application/vnd.datacite.datacite+json/#{doi}" +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["id"]).to eq("https://doi.org/10.7554/elife.01567") +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["id"]).to eq("https://doi.org/10.7554/elife.01567") - end - end +# it "link" do +# get "/application/vnd.datacite.datacite+json/#{doi}" - context "application/vnd.schemaorg.ld+json" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.schemaorg.ld+json" } +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["id"]).to eq("https://doi.org/10.7554/elife.01567") +# end +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["@type"]).to eq("ScholarlyArticle") - end +# context "application/vnd.schemaorg.ld+json" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.schemaorg.ld+json" } - it "link" do - get "/application/vnd.schemaorg.ld+json/#{doi}" +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["@type"]).to eq("ScholarlyArticle") +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["@type"]).to eq("ScholarlyArticle") - end - end +# it "link" do +# get "/application/vnd.schemaorg.ld+json/#{doi}" - context "application/ld+json" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/ld+json" } +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["@type"]).to eq("ScholarlyArticle") +# end +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["@type"]).to eq("ScholarlyArticle") - end +# context "application/ld+json" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/ld+json" } - it "link" do - get "/application/ld+json/#{doi}" +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["@type"]).to eq("ScholarlyArticle") +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["@type"]).to eq("ScholarlyArticle") - end - end +# it "link" do +# get "/application/ld+json/#{doi}" - context "application/vnd.citationstyles.csl+json" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["@type"]).to eq("ScholarlyArticle") +# end +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["type"]).to eq("article-journal") - end +# context "application/vnd.citationstyles.csl+json" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } - it "link" do - get "/application/vnd.citationstyles.csl+json/#{doi}" +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["type"]).to eq("article-journal") +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["type"]).to eq("article-journal") - end +# it "link" do +# get "/application/vnd.citationstyles.csl+json/#{doi}" - it "header crossref" do - get "/10.1186/1471-2164-7-187", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["type"]).to eq("article-journal") +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["type"]).to eq("article-journal") - expect(response["title"]).to eq("Finding function: evaluation methods for functional genomic data") - end +# it "header crossref" do +# get "/10.1186/1471-2164-7-187", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } - it "link crossref" do - get "/application/vnd.citationstyles.csl+json/10.1186/1471-2164-7-187" +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["type"]).to eq("article-journal") +# expect(response["title"]).to eq("Finding function: evaluation methods for functional genomic data") +# end - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["type"]).to eq("article-journal") - expect(response["title"]).to eq("Finding function: evaluation methods for functional genomic data") - end +# it "link crossref" do +# get "/application/vnd.citationstyles.csl+json/10.1186/1471-2164-7-187" - # it "doi with + character" do - # doi = "10.14454/terra+aqua/ceres/cldtyphist_l3.004" - # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["type"]).to eq("article-journal") +# expect(response["title"]).to eq("Finding function: evaluation methods for functional genomic data") +# end - # expect(last_response.status).to eq(200) - # response = JSON.parse(last_response.body) - # expect(response["type"]).to eq("dataset") - # end - end +# # it "doi with + character" do +# # doi = "10.14454/terra+aqua/ceres/cldtyphist_l3.004" +# # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } - context "application/x-research-info-systems" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-research-info-systems" } +# # expect(last_response.status).to eq(200) +# # response = JSON.parse(last_response.body) +# # expect(response["type"]).to eq("dataset") +# # end +# end - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("TY - JOUR") - end +# context "application/x-research-info-systems" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-research-info-systems" } - it "link" do - get "/application/x-research-info-systems/#{doi}" +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("TY - JOUR") +# end - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("TY - JOUR") - end - end +# it "link" do +# get "/application/x-research-info-systems/#{doi}" - context "application/x-bibtex" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-bibtex" } +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("TY - JOUR") +# end +# end - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("@article{https://doi.org/10.7554/elife.01567") - end +# context "application/x-bibtex" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-bibtex" } - it "link" do - get "/application/x-bibtex/#{doi}" +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("@article{https://doi.org/10.7554/elife.01567") +# end - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("@article{https://doi.org/10.7554/elife.01567") - end - end +# it "link" do +# get "/application/x-bibtex/#{doi}" - # context "application/rdf+xml" do - # it "header" do - # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/rdf+xml" } +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("@article{https://doi.org/10.7554/elife.01567") +# end +# end - # expect(last_response.status).to eq(200) - # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) - # expect(rdfxml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.7554/elife.01567") - # end +# # context "application/rdf+xml" do +# # it "header" do +# # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/rdf+xml" } - # it "link" do - # get "/application/rdf+xml/#{doi}" +# # expect(last_response.status).to eq(200) +# # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) +# # expect(rdfxml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.7554/elife.01567") +# # end - # expect(last_response.status).to eq(200) - # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) - # expect(rdfxml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.7554/elife.01567") - # end - # end +# # it "link" do +# # get "/application/rdf+xml/#{doi}" - # context "application/x-turtle" do - # it "header" do - # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-turtle" } +# # expect(last_response.status).to eq(200) +# # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) +# # expect(rdfxml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.7554/elife.01567") +# # end +# # end - # expect(last_response.status).to eq(200) - # ttl = last_response.body.split("\n") - # expect(ttl[0]).to eq("@prefix schema: .") - # expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") - # end +# # context "application/x-turtle" do +# # it "header" do +# # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-turtle" } - # it "link" do - # get "/application/x-turtle/#{doi}" +# # expect(last_response.status).to eq(200) +# # ttl = last_response.body.split("\n") +# # expect(ttl[0]).to eq("@prefix schema: .") +# # expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") +# # end - # expect(last_response.status).to eq(200) - # ttl = last_response.body.split("\n") - # expect(ttl[0]).to eq("@prefix schema: .") - # expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") - # end - # end +# # it "link" do +# # get "/application/x-turtle/#{doi}" - context "text/x-bibliography" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography" } - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("Sankar, M., Nieminen, K.") - end +# # expect(last_response.status).to eq(200) +# # ttl = last_response.body.split("\n") +# # expect(ttl[0]).to eq("@prefix schema: .") +# # expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") +# # end +# # end - it "header with style" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography; style=ieee" } - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("M. Sankar, K. Nieminen") - end +# context "text/x-bibliography" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography" } +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("Sankar, M., Nieminen, K.") +# end - it "header with style software apa" do - doi = "10.21373/1572872428618" - get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography; style=apa" } - expect(last_response.status).to eq(200) - expect(last_response.body).to eq("Miller, E. (2014). Full DataCite XML Example (Version 4.2) [Computer software]. DataCite. https://doi.org/10.21373/1572872428618") - end +# it "header with style" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography; style=ieee" } +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("M. Sankar, K. Nieminen") +# end - it "header with style and locale" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography; style=vancouver; locale=de" } - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("Sankar M") - end +# it "header with style software apa" do +# doi = "10.21373/1572872428618" +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography; style=apa" } +# expect(last_response.status).to eq(200) +# expect(last_response.body).to eq("Miller, E. (2014). Full DataCite XML Example (Version 4.2) [Computer software]. DataCite. https://doi.org/10.21373/1572872428618") +# end - it "link" do - get "/text/x-bibliography/#{doi}" +# it "header with style and locale" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography; style=vancouver; locale=de" } +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("Sankar M") +# end - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("Sankar, M., Nieminen, K.") - end +# it "link" do +# get "/text/x-bibliography/#{doi}" - it "link with style" do - get "/text/x-bibliography/#{doi}?style=ieee" +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("Sankar, M., Nieminen, K.") +# end - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("M. Sankar, K. Nieminen") - end +# it "link with style" do +# get "/text/x-bibliography/#{doi}?style=ieee" - it "link with style and locale" do - get "/text/x-bibliography/#{doi}?style=vancouver&locale=de" +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("M. Sankar, K. Nieminen") +# end - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("Sankar M") - end +# it "link with style and locale" do +# get "/text/x-bibliography/#{doi}?style=vancouver&locale=de" - it "link with style not found" do - get "/text/x-bibliography/#{doi}?style=mla" +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("Sankar M") +# end - # falling back to default APA style - expect(last_response.status).to eq(200) - expect(last_response.body).to eq("Sankar, M., Nieminen, K., Ragni, L., Xenarios, I., & Hardtke, C. S. (2014). Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth. ELife, 3, e01567. https://doi.org/10.7554/elife.01567") - end - end +# it "link with style not found" do +# get "/text/x-bibliography/#{doi}?style=mla" - context "unknown accept header" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/xml" } +# # falling back to default APA style +# expect(last_response.status).to eq(200) +# expect(last_response.body).to eq("Sankar, M., Nieminen, K., Ragni, L., Xenarios, I., & Hardtke, C. S. (2014). Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth. ELife, 3, e01567. https://doi.org/10.7554/elife.01567") +# end +# end - expect(last_response.status).to eq(303) - expect(last_response.headers["Location"]).to eq("https://elifesciences.org/articles/01567") - end +# context "unknown accept header" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/xml" } - it "link" do - get "/application/xml/#{doi}" +# expect(last_response.status).to eq(303) +# expect(last_response.headers["Location"]).to eq("https://elifesciences.org/articles/01567") +# end - expect(last_response.status).to eq(404) - expect(last_response.body).to eq("The resource you are looking for doesn't exist.") - end - end -end +# it "link" do +# get "/application/xml/#{doi}" + +# expect(last_response.status).to eq(404) +# expect(last_response.body).to eq("The resource you are looking for doesn't exist.") +# end +# end +# end + +# describe 'content negotiation medra', type: :api, vcr: true do +# let(:doi) { "10.1393/ncc/i2016-16378-6" } + +# context "application/vnd.jats+xml" do + +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.jats+xml" } + +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).dig("element_citation") +# expect(response.dig("pub_id")).to eq("__content__"=>"10.1393/ncc/i2016-16378-6", "pub_id_type"=>"doi") +# end + +# it "link" do +# get "/application/vnd.jats+xml/#{doi}" + +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).dig("element_citation") +# expect(response.dig("pub_id")).to eq("__content__"=>"10.1393/ncc/i2016-16378-6", "pub_id_type"=>"doi") +# end +# end + +# context "application/vnd.datacite.datacite+xml" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+xml" } + +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) +# expect(response.dig("publisher")).to eq("SIF") +# expect(response.dig("titles", "title")).to eq("Probing the nuclear symmetry energy at high densities with nuclear reactions") +# end + +# it "link" do +# get "/application/vnd.datacite.datacite+xml/#{doi}" + +# expect(last_response.status).to eq(200) +# response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) +# expect(response.dig("publisher")).to eq("SIF") +# expect(response.dig("titles", "title")).to eq("Probing the nuclear symmetry energy at high densities with nuclear reactions") +# end + +# it "not found" do +# doi = "10.15146/R34015" +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+xml" } + +# expect(last_response.status).to eq(404) +# expect(last_response.body).to eq("The resource you are looking for doesn't exist.") +# end +# end + +# context "application/vnd.datacite.datacite+json" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+json" } + +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["id"]).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# end + +# it "link" do +# get "/application/vnd.datacite.datacite+json/#{doi}" + +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["id"]).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# end +# end + +# context "application/vnd.schemaorg.ld+json" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.schemaorg.ld+json" } + +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["@type"]).to eq("ScholarlyArticle") +# end + +# it "link" do +# get "/application/vnd.schemaorg.ld+json/#{doi}" + +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["@type"]).to eq("ScholarlyArticle") +# end +# end + +# context "application/vnd.citationstyles.csl+json" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } + +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["type"]).to eq("article-journal") +# end + +# it "link" do +# get "/application/vnd.citationstyles.csl+json/#{doi}" + +# expect(last_response.status).to eq(200) +# response = JSON.parse(last_response.body) +# expect(response["type"]).to eq("article-journal") +# end + +# # it "doi with + character" do +# # doi = "10.14454/terra+aqua/ceres/cldtyphist_l3.004" +# # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } + +# # expect(last_response.status).to eq(200) +# # response = JSON.parse(last_response.body) +# # expect(response["type"]).to eq("dataset") +# # end +# end + +# context "application/x-research-info-systems" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-research-info-systems" } + +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("TY - GEN") +# end + +# it "link" do +# get "/application/x-research-info-systems/#{doi}" + +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("TY - GEN") +# end +# end + +# context "application/x-bibtex" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-bibtex" } + +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("@article{https://doi.org/10.1393/ncc/i2016-16378-6") +# end + +# it "link" do +# get "/application/x-bibtex/#{doi}" + +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("@article{https://doi.org/10.1393/ncc/i2016-16378-6") +# end +# end + +# # context "application/rdf+xml" do +# # it "header" do +# # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/rdf+xml" } + +# # expect(last_response.status).to eq(200) +# # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) +# # expect(rdfxml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# # end + +# # it "link" do +# # get "/application/rdf+xml/#{doi}" + +# # expect(last_response.status).to eq(200) +# # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) +# # expect(rdfxml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# # end +# # end + +# # context "application/x-turtle" do +# # it "header" do +# # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-turtle" } + +# # expect(last_response.status).to eq(200) +# # ttl = last_response.body.split("\n") +# # expect(ttl[0]).to eq("@prefix schema: .") +# # expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") +# # end + +# # it "link" do +# # get "/application/x-turtle/#{doi}" + +# # expect(last_response.status).to eq(200) +# # ttl = last_response.body.split("\n") +# # expect(ttl[0]).to eq("@prefix schema: .") +# # expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") +# # end +# # end + +# context "text/x-bibliography" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography" } +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("Probing the nuclear symmetry energy") +# end + +# it "link" do +# get "/text/x-bibliography/#{doi}" + +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("Probing the nuclear symmetry energy") +# end + +# it "link with style" do +# get "/text/x-bibliography/#{doi}?style=ieee" + +# expect(last_response.status).to eq(200) +# expect(last_response.body).to eq("“Probing the nuclear symmetry energy at high densities with nuclear reactions,” Il Nuovo Cimento C, vol. 39, no. 6, pp. 1–10, Mar. 2017, doi: 10.1393/ncc/i2016-16378-6.") +# end + +# it "link with style and locale" do +# get "/text/x-bibliography/#{doi}?style=vancouver&locale=de" + +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("Probing the nuclear symmetry energy") +# end + +# it "link with style not found" do +# get "/text/x-bibliography/#{doi}?style=mla" + +# # falling back to default APA style +# expect(last_response.status).to eq(200) +# expect(last_response.body).to eq("Probing the nuclear symmetry energy at high densities with nuclear reactions. (2017). Il Nuovo Cimento C, 39(6), 1–10. https://doi.org/10.1393/ncc/i2016-16378-6") +# end +# end + +# context "unknown accept header" do +# it "header" do +# get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/xml" } + +# expect(last_response.status).to eq(303) +# expect(last_response.headers["Location"]).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# end + +# it "link" do +# get "/application/xml/#{doi}" + +# expect(last_response.status).to eq(404) +# expect(last_response.body).to eq("The resource you are looking for doesn't exist.") +# end +# end +# end -# describe 'content negotiation medra', type: :api, vcr: true do -# let(:doi) { "10.1393/ncc/i2016-16378-6" } +# describe 'content negotiation jalc', type: :api, vcr: true do +# let(:doi) { "10.18942/apg.201812" } # context "application/vnd.jats+xml" do @@ -632,7 +869,7 @@ # expect(last_response.status).to eq(200) # response = Maremma.from_xml(last_response.body).dig("element_citation") -# expect(response.dig("pub_id")).to eq("__content__"=>"10.1393/ncc/i2016-16378-6", "pub_id_type"=>"doi") +# expect(response.dig("pub_id")).to eq("__content__"=>"10.18942/apg.201812", "pub_id_type"=>"doi") # end # it "link" do @@ -640,7 +877,7 @@ # expect(last_response.status).to eq(200) # response = Maremma.from_xml(last_response.body).dig("element_citation") -# expect(response.dig("pub_id")).to eq("__content__"=>"10.1393/ncc/i2016-16378-6", "pub_id_type"=>"doi") +# expect(response.dig("pub_id")).to eq("__content__"=>"10.18942/apg.201812", "pub_id_type"=>"doi") # end # end @@ -650,8 +887,8 @@ # expect(last_response.status).to eq(200) # response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) -# expect(response.dig("publisher")).to eq("SIF") -# expect(response.dig("titles", "title")).to eq("Probing the nuclear symmetry energy at high densities with nuclear reactions") +# expect(response.dig("publisher")).to eq("The Japanese Society for Plant Systematics") +# expect(response.dig("titles", "title")).to eq("Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales)") # end # it "link" do @@ -659,8 +896,8 @@ # expect(last_response.status).to eq(200) # response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) -# expect(response.dig("publisher")).to eq("SIF") -# expect(response.dig("titles", "title")).to eq("Probing the nuclear symmetry energy at high densities with nuclear reactions") +# expect(response.dig("publisher")).to eq("The Japanese Society for Plant Systematics") +# expect(response.dig("titles", "title")).to eq("Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales)") # end # it "not found" do @@ -678,7 +915,7 @@ # expect(last_response.status).to eq(200) # response = JSON.parse(last_response.body) -# expect(response["id"]).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# expect(response["id"]).to eq("https://doi.org/10.18942/apg.201812") # end # it "link" do @@ -686,7 +923,7 @@ # expect(last_response.status).to eq(200) # response = JSON.parse(last_response.body) -# expect(response["id"]).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# expect(response["id"]).to eq("https://doi.org/10.18942/apg.201812") # end # end @@ -696,7 +933,7 @@ # expect(last_response.status).to eq(200) # response = JSON.parse(last_response.body) -# expect(response["@type"]).to eq("ScholarlyArticle") +# expect(response["@type"]).to eq("CreativeWork") # end # it "link" do @@ -704,7 +941,7 @@ # expect(last_response.status).to eq(200) # response = JSON.parse(last_response.body) -# expect(response["@type"]).to eq("ScholarlyArticle") +# expect(response["@type"]).to eq("CreativeWork") # end # end @@ -714,7 +951,7 @@ # expect(last_response.status).to eq(200) # response = JSON.parse(last_response.body) -# expect(response["type"]).to eq("article-journal") +# expect(response["title"]).to eq("Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales)") # end # it "link" do @@ -722,7 +959,7 @@ # expect(last_response.status).to eq(200) # response = JSON.parse(last_response.body) -# expect(response["type"]).to eq("article-journal") +# expect(response["title"]).to eq("Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales)") # end # # it "doi with + character" do @@ -756,14 +993,14 @@ # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-bibtex" } # expect(last_response.status).to eq(200) -# expect(last_response.body).to start_with("@article{https://doi.org/10.1393/ncc/i2016-16378-6") +# expect(last_response.body).to start_with("@misc{https://doi.org/10.18942/apg.201812") # end # it "link" do # get "/application/x-bibtex/#{doi}" # expect(last_response.status).to eq(200) -# expect(last_response.body).to start_with("@article{https://doi.org/10.1393/ncc/i2016-16378-6") +# expect(last_response.body).to start_with("@misc{https://doi.org/10.18942/apg.201812") # end # end @@ -773,7 +1010,7 @@ # # expect(last_response.status).to eq(200) # # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) -# # expect(rdfxml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# # expect(rdfxml.dig("CreativeWork", "rdf:about")).to eq("https://doi.org/10.18942/apg.201812") # # end # # it "link" do @@ -781,7 +1018,7 @@ # # expect(last_response.status).to eq(200) # # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) -# # expect(rdfxml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# # expect(rdfxml.dig("CreativeWork", "rdf:about")).to eq("https://doi.org/10.18942/apg.201812") # # end # # end @@ -792,7 +1029,7 @@ # # expect(last_response.status).to eq(200) # # ttl = last_response.body.split("\n") # # expect(ttl[0]).to eq("@prefix schema: .") -# # expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") +# # expect(ttl[2]).to eq(" a schema:CreativeWork;") # # end # # it "link" do @@ -801,7 +1038,7 @@ # # expect(last_response.status).to eq(200) # # ttl = last_response.body.split("\n") # # expect(ttl[0]).to eq("@prefix schema: .") -# # expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") +# # expect(ttl[2]).to eq(" a schema:CreativeWork;") # # end # # end @@ -809,28 +1046,28 @@ # it "header" do # get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography" } # expect(last_response.status).to eq(200) -# expect(last_response.body).to start_with("Probing the nuclear symmetry energy") +# expect(last_response.body).to start_with("Ebihara, A., Nakato, N.") # end # it "link" do # get "/text/x-bibliography/#{doi}" # expect(last_response.status).to eq(200) -# expect(last_response.body).to start_with("Probing the nuclear symmetry energy") +# expect(last_response.body).to start_with("Ebihara, A., Nakato, N.") # end # it "link with style" do # get "/text/x-bibliography/#{doi}?style=ieee" # expect(last_response.status).to eq(200) -# expect(last_response.body).to eq("“Probing the nuclear symmetry energy at high densities with nuclear reactions,” Il Nuovo Cimento C, vol. 39, no. 6, pp. 1–10, Mar. 2017, doi: 10.1393/ncc/i2016-16378-6.") +# expect(last_response.body).to start_with("A. Ebihara, N. Nakato") # end # it "link with style and locale" do # get "/text/x-bibliography/#{doi}?style=vancouver&locale=de" # expect(last_response.status).to eq(200) -# expect(last_response.body).to start_with("Probing the nuclear symmetry energy") +# expect(last_response.body).to eq("Ebihara A, Nakato N, Kuo L-Y, Miyazaki H, Serizawa S. Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales) [Internet]. Bd. 70, Acta phytotaxonomica et geobotanica. The Japanese Society for Plant Systematics; 2019. S. 19–28. Verfügbar unter: https://doi.org/10.18942/apg.201812") # end # it "link with style not found" do @@ -838,7 +1075,14 @@ # # falling back to default APA style # expect(last_response.status).to eq(200) -# expect(last_response.body).to eq("Probing the nuclear symmetry energy at high densities with nuclear reactions. (2017). Il Nuovo Cimento C, 39(6), 1–10. https://doi.org/10.1393/ncc/i2016-16378-6") +# expect(last_response.body).to eq("Ebihara, A., Nakato, N., Kuo, L.-Y., Miyazaki, H., & Serizawa, S. (2019). Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales). In Acta phytotaxonomica et geobotanica (Vol. 70, pp. 19–28). The Japanese Society for Plant Systematics. https://doi.org/10.18942/apg.201812") +# end + +# it "link with style" do +# get "/text/x-bibliography/#{doi}?style=ieee" + +# expect(last_response.status).to eq(200) +# expect(last_response.body).to start_with("A. Ebihara, N. Nakato") # end # end @@ -847,7 +1091,7 @@ # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/xml" } # expect(last_response.status).to eq(303) -# expect(last_response.headers["Location"]).to eq("https://doi.org/10.1393/ncc/i2016-16378-6") +# expect(last_response.headers["Location"]).to eq("https://doi.org/10.18942/apg.201812") # end # it "link" do @@ -857,259 +1101,15 @@ # expect(last_response.body).to eq("The resource you are looking for doesn't exist.") # end # end -# end - -describe 'content negotiation jalc', type: :api, vcr: true do - let(:doi) { "10.18942/apg.201812" } - - context "application/vnd.jats+xml" do - - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.jats+xml" } - - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).dig("element_citation") - expect(response.dig("pub_id")).to eq("__content__"=>"10.18942/apg.201812", "pub_id_type"=>"doi") - end - - it "link" do - get "/application/vnd.jats+xml/#{doi}" - - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).dig("element_citation") - expect(response.dig("pub_id")).to eq("__content__"=>"10.18942/apg.201812", "pub_id_type"=>"doi") - end - end - - context "application/vnd.datacite.datacite+xml" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+xml" } - - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) - expect(response.dig("publisher")).to eq("The Japanese Society for Plant Systematics") - expect(response.dig("titles", "title")).to eq("Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales)") - end - - it "link" do - get "/application/vnd.datacite.datacite+xml/#{doi}" - - expect(last_response.status).to eq(200) - response = Maremma.from_xml(last_response.body).to_h.fetch("resource", {}) - expect(response.dig("publisher")).to eq("The Japanese Society for Plant Systematics") - expect(response.dig("titles", "title")).to eq("Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales)") - end - - it "not found" do - doi = "10.15146/R34015" - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+xml" } - - expect(last_response.status).to eq(404) - expect(last_response.body).to eq("The resource you are looking for doesn't exist.") - end - end - - context "application/vnd.datacite.datacite+json" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.datacite.datacite+json" } - - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["id"]).to eq("https://doi.org/10.18942/apg.201812") - end - - it "link" do - get "/application/vnd.datacite.datacite+json/#{doi}" - - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["id"]).to eq("https://doi.org/10.18942/apg.201812") - end - end - - context "application/vnd.schemaorg.ld+json" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.schemaorg.ld+json" } - - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["@type"]).to eq("CreativeWork") - end - - it "link" do - get "/application/vnd.schemaorg.ld+json/#{doi}" - - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["@type"]).to eq("CreativeWork") - end - end - - context "application/vnd.citationstyles.csl+json" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } - - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["title"]).to eq("Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales)") - end - - it "link" do - get "/application/vnd.citationstyles.csl+json/#{doi}" - - expect(last_response.status).to eq(200) - response = JSON.parse(last_response.body) - expect(response["title"]).to eq("Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales)") - end - - # it "doi with + character" do - # doi = "10.14454/terra+aqua/ceres/cldtyphist_l3.004" - # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/vnd.citationstyles.csl+json" } - - # expect(last_response.status).to eq(200) - # response = JSON.parse(last_response.body) - # expect(response["type"]).to eq("dataset") - # end - end - - context "application/x-research-info-systems" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-research-info-systems" } - - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("TY - GEN") - end - - it "link" do - get "/application/x-research-info-systems/#{doi}" - - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("TY - GEN") - end - end - - context "application/x-bibtex" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-bibtex" } - - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("@misc{https://doi.org/10.18942/apg.201812") - end - - it "link" do - get "/application/x-bibtex/#{doi}" - - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("@misc{https://doi.org/10.18942/apg.201812") - end - end - - # context "application/rdf+xml" do - # it "header" do - # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/rdf+xml" } - - # expect(last_response.status).to eq(200) - # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) - # expect(rdfxml.dig("CreativeWork", "rdf:about")).to eq("https://doi.org/10.18942/apg.201812") - # end - - # it "link" do - # get "/application/rdf+xml/#{doi}" - - # expect(last_response.status).to eq(200) - # rdfxml = Maremma.from_xml(last_response.body).fetch("RDF", {}) - # expect(rdfxml.dig("CreativeWork", "rdf:about")).to eq("https://doi.org/10.18942/apg.201812") - # end - # end - - # context "application/x-turtle" do - # it "header" do - # get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/x-turtle" } - - # expect(last_response.status).to eq(200) - # ttl = last_response.body.split("\n") - # expect(ttl[0]).to eq("@prefix schema: .") - # expect(ttl[2]).to eq(" a schema:CreativeWork;") - # end - - # it "link" do - # get "/application/x-turtle/#{doi}" - - # expect(last_response.status).to eq(200) - # ttl = last_response.body.split("\n") - # expect(ttl[0]).to eq("@prefix schema: .") - # expect(ttl[2]).to eq(" a schema:CreativeWork;") - # end - # end - - context "text/x-bibliography" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "text/x-bibliography" } - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("Ebihara, A., Nakato, N.") - end - - it "link" do - get "/text/x-bibliography/#{doi}" - - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("Ebihara, A., Nakato, N.") - end - - it "link with style" do - get "/text/x-bibliography/#{doi}?style=ieee" - - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("A. Ebihara, N. Nakato") - end - - it "link with style and locale" do - get "/text/x-bibliography/#{doi}?style=vancouver&locale=de" - - expect(last_response.status).to eq(200) - expect(last_response.body).to eq("Ebihara A, Nakato N, Kuo L-Y, Miyazaki H, Serizawa S. Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales) [Internet]. Bd. 70, Acta phytotaxonomica et geobotanica. The Japanese Society for Plant Systematics; 2019. S. 19–28. Verfügbar unter: https://doi.org/10.18942/apg.201812") - end - - it "link with style not found" do - get "/text/x-bibliography/#{doi}?style=mla" - - # falling back to default APA style - expect(last_response.status).to eq(200) - expect(last_response.body).to eq("Ebihara, A., Nakato, N., Kuo, L.-Y., Miyazaki, H., & Serizawa, S. (2019). Allopolyploid Origin and Distribution Range of Acystopteris taiwaniana (Cystopteridaceae: Polypodiales). In Acta phytotaxonomica et geobotanica (Vol. 70, pp. 19–28). The Japanese Society for Plant Systematics. https://doi.org/10.18942/apg.201812") - end - - it "link with style" do - get "/text/x-bibliography/#{doi}?style=ieee" - - expect(last_response.status).to eq(200) - expect(last_response.body).to start_with("A. Ebihara, N. Nakato") - end - end - - context "unknown accept header" do - it "header" do - get "/#{doi}", nil, { "HTTP_ACCEPT" => "application/xml" } - - expect(last_response.status).to eq(303) - expect(last_response.headers["Location"]).to eq("https://doi.org/10.18942/apg.201812") - end - it "link" do - get "/application/xml/#{doi}" +# describe 'rmethod not allowed error', type: :api do +# let(:doi) { "10.14454/cne7-ar31" } - expect(last_response.status).to eq(404) - expect(last_response.body).to eq("The resource you are looking for doesn't exist.") - end - end +# it "post" do +# post "/#{doi}" - describe 'rmethod not allowed error', type: :api do - let(:doi) { "10.14454/cne7-ar31" } - - it "post" do - post "/#{doi}" - - expect(last_response.status).to eq(405) - expect(last_response.body).to eq("Method not allowed.") - end - end -end +# expect(last_response.status).to eq(405) +# expect(last_response.body).to eq("Method not allowed.") +# end +# end +# end