Sha256: 553da5479b60c14ca60c5b02872d0d4bf0868e14929c68a059694593427a604d

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe(Jekyll::Authors) do
  let(:overrides) { Hash.new }
  let(:config) do
    Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
      "full_rebuild" => true,
      "source"      => source_dir,
      "destination" => dest_dir,
      "show_drafts" => true,
      "url"         => "http://example.org",
      "name"       => "My awesome site",
      "collections" => {
        "my_collection" => { "output" => true },
        "other_things"  => { "output" => false }
      }
    }, overrides))
  end
  let(:site)     { Jekyll::Site.new(config) }
  let(:generated_page) { File.read(dest_dir("2013/12/12/dec-the-second.html")) }
  let(:context)  { make_context(site: site) }
  before(:each) do
    site.process
  end

  it "has authors from _config.yml" do
    expect(site.config['authors']['garthdb']['name']).to match(/\AGarth Braithwaite/)
  end

  it "has authors from _data/authors.yml" do
    expect(site.config['authors']['pathawks']['name']).to match(/\APat Hawks/)
  end

  it "prioritizes _config.yml data" do
    expect(site.config['authors']['benbalter']['name']).to match('Ben Balter')
  end

  it "uses authors data for page author" do
    expect(generated_page).to match(/Garth Braithwaite/)
  end

  it "leaves the string if it doesn't match author key" do
    page = File.read(dest_dir("2014/08/13/non-author.html"))
    expect(page).to match(/Tester McTesterton/)
  end

  it "sets default author from the first author in list if not set" do
    expect(site.config['author']['name']).to match('Garth Braithwaite')
  end

  context "a default author set in config" do
    let(:author) {"Dr. Jekyll"}
    let(:overrides) do
      {"author" => author}
    end
    it "does not override config author if set" do
      expect(site.config['author']).to match(author)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-author-0.1.0 spec/jekyll-author_spec.rb