Sha256: 87feca00cbd9b9b076dac95b5957efb48e82134979bc87e7e883759b220f6eb5

Contents?: true

Size: 1.65 KB

Versions: 5

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Kitabu::Exporter::HTML do
  let(:root) { SPECDIR.join("support/mybook") }
  let(:format) { described_class.new(root) }

  context "when generating HTML" do
    let(:file) { SPECDIR.join("support/mybook/output/mybook.html") }
    let(:html) { File.read(file) }
    before { format.export }

    it "generates valid markup", osx: Kitabu::Dependency.macos? do
      `./vendor/bin/tidy5_osx '#{file}' 2>&1 > /dev/null`
      expect($CHILD_STATUS.exitstatus).to eq(0)
    end

    it "generates valid markup", linux: Kitabu::Dependency.linux? do
      `./vendor/bin/tidy5_linux '#{file}' 2>&1 > /dev/null`
      expect($CHILD_STATUS.exitstatus).to eq(0)
    end

    it "keeps html file around" do
      expect(file).to be_file
    end

    it "has several chapters" do
      expect(html).to have_tag("div.chapter", 3)
    end

    it "uses config file" do
      expect(html).to have_tag("div.imprint p", "Copyright (C) 2010 John Doe.")
    end

    it "renders changelog" do
      expect(html).to have_tag("div.changelog h2", "Revisions")
    end

    it "renders erb" do
      expect(html).to have_tag("h2", "ERB")
    end

    it "renders erb blocks" do
      expect(html).to have_tag("div.note.info > p", "This is a note!")
    end

    it "copies fonts" do
      expect(root.join("output/fonts/OpenSans-CondBold.ttf")).to be_file
    end

    it "exports css files" do
      expect(root.join("output/styles/epub.css")).to be_file
      expect(root.join("output/styles/html.css")).to be_file
      expect(root.join("output/styles/pdf.css")).to be_file
      expect(root.join("output/styles/print.css")).to be_file
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kitabu-3.1.0 spec/kitabu/exporter/html_spec.rb
kitabu-3.0.3 spec/kitabu/exporter/html_spec.rb
kitabu-3.0.2 spec/kitabu/exporter/html_spec.rb
kitabu-3.0.1 spec/kitabu/exporter/html_spec.rb
kitabu-3.0.0 spec/kitabu/exporter/html_spec.rb