# frozen_string_literal: true require 'spec_helper' describe Briard::Metadata, vcr: true do context "write metadata as turtle" do it "Crossref DOI" do input = fixture_path + "crossref.bib" subject = Briard::Metadata.new(input: input, from: "bibtex") ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") end it "Dataset" do input = "https://doi.org/10.5061/DRYAD.8515" subject = Briard::Metadata.new(input: input, from: "datacite") expect(subject.valid?).to be true ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:Dataset;") end it "BlogPosting" do input= "https://doi.org/10.5438/4K3M-NYVG" subject = Briard::Metadata.new(input: input, from: "datacite") expect(subject.valid?).to be true ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") end it "BlogPosting Citeproc JSON" do input = fixture_path + "citeproc.json" subject = Briard::Metadata.new(input: input, from: "citeproc") ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:BlogPosting;") end it "BlogPosting DataCite JSON" do input = fixture_path + "datacite.json" subject = Briard::Metadata.new(input: input, from: "datacite_json") ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") end it "BlogPosting schema.org" do input = "https://blog.front-matter.io/posts/eating-your-own-dog-food//" subject = Briard::Metadata.new(input: input, from: "schema_org") expect(subject.valid?).to be true ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:Article;") expect(ttl[3]).to eq(" schema:author ;") end it "DataONE" do input = fixture_path + 'codemeta.json' subject = Briard::Metadata.new(input: input, from: "codemeta") ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:SoftwareSourceCode;") end it "journal article" do input = "10.7554/eLife.01567" subject = Briard::Metadata.new(input: input, from: "crossref") expect(subject.valid?).to be true ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") end it "with pages" do input = "https://doi.org/10.1155/2012/291294" subject = Briard::Metadata.new(input: input, from: "crossref") expect(subject.valid?).to be true ttl = subject.turtle.split("\n") expect(ttl[0]).to eq("@prefix schema: .") expect(ttl[2]).to eq(" a schema:ScholarlyArticle;") end end end