Sha256: 3c099b86222c2f59515645e3af71426b1f25afd2e4b26f68d2bb28f1dc84f5d9

Contents?: true

Size: 1.57 KB

Versions: 15

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe Bergamasco::Summarize do
  subject { Bergamasco::Summarize }

  it 'should truncate after 250 characters' do
    filepath = fixture_path + 'cool-dois-without-yml.md'
    file = IO.read(filepath)
    content = subject.summary(file, length: 250)
    expect(content.length).to eq(250)
    expect(content).to start_with("In 1998 Tim Berners-Lee coined")
  end

  it 'should truncate after 75 characters' do
    filepath = fixture_path + 'cool-dois-without-yml.md'
    file = IO.read(filepath)
    content = subject.summary(file, length: 75)
    expect(content.length).to eq(83)
    expect(content).to start_with("In 1998 Tim Berners-Lee coined")
  end

  it 'should truncate at separator' do
    filepath = fixture_path + 'cool-dois-without-yml.md'
    file = IO.read(filepath)
    content = subject.summary(file)
    expect(content).to start_with("In 1998 Tim Berners-Lee coined")
    expect(content).to end_with("the referenced resource.")
  end

  it 'should truncate at separator and convert to html' do
    filepath = fixture_path + 'cool-dois-without-yml.md'
    file = IO.read(filepath)
    html = Bergamasco::Pandoc.convert(file, skip_yaml_header: true, csl: 'spec/fixtures/apa.csl', bibliography: 'spec/fixtures/references.bib')
    content = subject.summary_from_html(html, skip_yaml_header: true, csl: 'spec/fixtures/apa.csl', bibliography: 'spec/fixtures/references.bib')
    expect(content).to start_with("In 1998 Tim Berners-Lee coined the term cool URIs (1998), that is URIs that don’t change.")
    expect(content).to end_with("the referenced resource.")
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
bergamasco-0.3.17 spec/summarize_spec.rb
bergamasco-0.3.16 spec/summarize_spec.rb
bergamasco-0.3.15 spec/summarize_spec.rb
bergamasco-0.3.14 spec/summarize_spec.rb
bergamasco-0.3.13 spec/summarize_spec.rb
bergamasco-0.3.12 spec/summarize_spec.rb
bergamasco-0.3.11 spec/summarize_spec.rb
bergamasco-0.3.10 spec/summarize_spec.rb
bergamasco-0.3.9 spec/summarize_spec.rb
bergamasco-0.3.8 spec/summarize_spec.rb
bergamasco-0.3.7 spec/summarize_spec.rb
bergamasco-0.3.6 spec/summarize_spec.rb
bergamasco-0.3.5 spec/summarize_spec.rb
bergamasco-0.3.4 spec/summarize_spec.rb
bergamasco-0.3.3 spec/summarize_spec.rb