Sha256: 43f7b94511696a66db1ff775b2b9d8d1f91fd79d5230b8d5635c3a7c789505b8

Contents?: true

Size: 1.83 KB

Versions: 7

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'

describe Softcover::BookManifest do
  context "with book generation" do
    before(:all) { generate_book }
    after(:all)  { remove_book }
    subject(:manifest) { Softcover::BookManifest.new }

    context "in valid book directory" do

      describe "basic information" do
        its(:title) { should eq "book" }
        its(:subtitle) { should eq "Change-me" }
        its(:description) { should eq "Change me." }
        its(:cover) { should eq "images/cover.png" }
        its(:author) { should eq "Author Name" }
      end

      describe "chapter information" do
        subject(:chapter) { manifest.chapters[1] }
        it { should be_a Softcover::BookManifest::Chapter }
        its(:title) { should eq "A chapter" }
        its(:slug) { should eq "a_chapter" }
        its(:chapter_number) { should eq 1 }
        its("sections.first.name") do
          should eq 'A section'
        end

        describe "for second chapter" do
          subject(:chapter) { manifest.chapters[2] }
          its(:title) { should eq 'Another chapter' }
          its(:slug) { should eq "another_chapter" }
          its(:chapter_number) { should eq 2 }
        end

        describe "for third chapter" do
          subject(:chapter) { manifest.chapters[3] }
          its(:title) { should eq 'Yet \emph{another} chapter' }
          its(:slug) { should eq "yet_another_chapter" }
          its(:chapter_number) { should eq 3 }
        end
      end
    end

    context "in a valid book subdirectory" do
      before { Dir.chdir 'chapters' }
      describe "finding the manifest in a higher directory" do
        its(:title) { should eq "book" }
      end
    end
  end

  context "in an invalid book directory" do
    it "raises an error when manifest missing" do
      expect{ subject }.to raise_error(Softcover::BookManifest::NotFound)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
softcover-0.6.5 spec/book_manifest_spec.rb
softcover-0.6.4 spec/book_manifest_spec.rb
softcover-0.6.3 spec/book_manifest_spec.rb
softcover-0.6.2 spec/book_manifest_spec.rb
softcover-0.6.1 spec/book_manifest_spec.rb
softcover-0.6.0 spec/book_manifest_spec.rb
softcover-0.5.0 spec/book_manifest_spec.rb