Sha256: 29308e6211a6002e673b6ee099ed06126a525e0da337c0d1d7ae9a74a87bf4cb

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

describe Bergamasco::Pandoc do
  subject { Bergamasco::Pandoc }

  it 'should convert markdown' do
    filepath = fixture_path + 'cool-dois.html.md'
    file = IO.read(filepath)
    html = subject.convert(file, skip_yaml_header: true, csl: 'spec/fixtures/apa.csl', bibliography: 'spec/fixtures/references.yaml')
    expect(html).to start_with("<p>In 1998 Tim Berners-Lee coined the term cool URIs <span class=\"citation\">(1998)</span>, that is URIs that don’t change.")
  end

  it 'should convert to jats' do
    filepath = fixture_path + 'cool-dois.html.md'
    file = IO.read(filepath)
    xml = subject.convert_to_jats(file, skip_yaml_header: true, csl: 'spec/fixtures/apa.csl', bibliography: 'spec/fixtures/references.yaml')
    doc = Nokogiri::XML(xml)
    article_id = doc.at_xpath("//article-id")
    expect(article_id.text).to eq("10.5072/0000-03VC")
    expect(article_id.values.first).to eq("doi")
  end

  it 'should write jats xml' do
    input_path = fixture_path + 'cool-dois.html.md'
    output_path = fixture_path + 'cool-dois.xml'
    xml_path = subject.write_jats(input_path, output_path, skip_yaml_header: true, csl: 'spec/fixtures/apa.csl', bibliography: 'spec/fixtures/references.yaml')
    doc = File.open(xml_path) { |f| Nokogiri::XML(f) }
    article_id = doc.at_xpath("//article-id")
    expect(article_id.text).to eq("10.5072/0000-03VC")
    expect(article_id.values.first).to eq("doi")
  end

  it 'should write bibliography to yaml' do
    bib_path = fixture_path + 'references.bib'
    yaml_path = fixture_path + 'references.yaml'
    yaml = subject.write_bibliograpy_to_yaml(bib_path, yaml_path)
    expect(yaml["references"].length).to eq(61)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bergamasco-0.3.8 spec/pandoc_spec.rb
bergamasco-0.3.7 spec/pandoc_spec.rb