Sha256: a19423e705fbb0a252e023c4205b3355e4a6f660296a08dd187dc2eebc015714

Contents?: true

Size: 1.78 KB

Versions: 14

Compression:

Stored size: 1.78 KB

Contents

require 'test_helper'
require 'review/catalog'

class CatalogTest < Test::Unit::TestCase
  include ReVIEW

  def test_predef
    sut = Catalog.new(yaml)
    exp =<<-EOS
pre01.re
pre02.re
    EOS
    assert_equal(exp.chomp, sut.predef)
  end

  def test_chaps
    sut = Catalog.new(yaml)
    exp =<<-EOS
ch01.re
ch02.re
    EOS
    assert_equal(exp.chomp, sut.chaps)
  end

  def test_chaps_empty
    yaml = StringIO.new
    sut = Catalog.new(yaml)
    assert_equal("", sut.chaps)
  end

  def test_appendix
    sut = Catalog.new(yaml)
    exp =<<-EOS
post01.re
post02.re
    EOS
    assert_equal(exp.chomp, sut.appendix)
  end

  def test_chaps_with_parts
    sut = Catalog.new(yaml_with_parts)
    exp =<<-EOS
ch01.re
ch02.re
ch03.re
ch04.re
ch05.re
    EOS
    assert_equal(exp.chomp, sut.chaps)
  end

  def test_parts
    sut = Catalog.new(yaml_with_parts)
    exp =<<-EOS
part1.re
part2.re
    EOS
    assert_equal(exp.chomp, sut.parts)
  end

  def test_parts_with_empty
    sut = Catalog.new(yaml)
    assert_equal("", sut.parts)
  end

  def test_parts2
    sut = Catalog.new(yaml_with_parts)
    assert_equal(["ch01.re",
                  {"part1.re" => ["ch02.re"]},
                  "ch03.re",
                  {"part2.re" => ["ch04.re", "ch05.re"]}],
                 sut.parts_with_chaps)
  end

  def test_postdef
    sut = Catalog.new(yaml)
    exp =<<-EOS
back01.re
back02.re
    EOS
    assert_equal(exp.chomp, sut.postdef)
  end

  private
  def yaml
    StringIO.new <<-EOS

PREDEF:
  - pre01.re
  - pre02.re

CHAPS:
  - ch01.re
  - ch02.re

APPENDIX:
  - post01.re
  - post02.re

POSTDEF:
  - back01.re
  - back02.re
    EOS
  end

  def yaml_with_parts
    StringIO.new <<-EOS
CHAPS:
  - ch01.re
  - part1.re:
    - ch02.re
  - ch03.re
  - part2.re:
    - ch04.re
    - ch05.re

    EOS
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
review-1.7.2 test/test_catalog.rb
review-1.7.1 test/test_catalog.rb
review-peg-0.2.2 test/test_catalog.rb
review-peg-0.2.1 test/test_catalog.rb
review-peg-0.2.0 test/test_catalog.rb
review-peg-0.1.3 test/test_catalog.rb
review-peg-0.1.2 test/test_catalog.rb
review-peg-0.1.1 test/test_catalog.rb
review-peg-0.1.0 test/test_catalog.rb
review-1.7.0 test/test_catalog.rb
review-1.6.0 test/test_catalog.rb
review-2.0.0.beta1 test/test_catalog.rb
review-1.5.0 test/test_catalog.rb
review-1.4.0 test/test_catalog.rb