Sha256: e4527a99af3bb7e3886475f5d9b1cb45ce487302e356795f8d72f72ff6778e16

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

require 'book_test_helper'
class PartTest < Test::Unit::TestCase
  include BookTestHelper

  def test_initialize
    book = Book::Base.new
    part = Book::Part.new(book, nil, nil)
    assert_equal nil, part.number
    assert_equal nil, part.chapters
    assert_equal '', part.name

    part = Book::Part.new(book, 123, [], 'name')
    assert_equal 123, part.number
    assert_equal [], part.chapters
    assert_equal 'name', part.name
  end

  def test_each_chapter
    part = Book::Part.new(nil, nil, [1, 2, 3])

    tmp = []
    part.each_chapter { |ch| tmp << ch }
    assert_equal [1, 2, 3], tmp
  end

  def test_volume
    book = Book::Base.new
    part = Book::Part.new(book, nil, [])
    assert part.volume
    assert_equal 0, part.volume.bytes
    assert_equal 0, part.volume.chars
    assert_equal 0, part.volume.lines

    chs = []
    tfs = [] ## prevent from removing Tempfile
    Tempfile.open('part_test') do |o|
      o.print '12345'
      chs << Book::Chapter.new(book, nil, nil, o.path)
      tfs << o
    end
    Tempfile.open('part_test') do |o|
      o.print '67890'
      chs << Book::Chapter.new(book, nil, nil, o.path)
      tfs << o
    end

    part = Book::Part.new(book, nil, chs)
    assert part.volume
    assert part.volume.bytes > 0
    assert part.volume.chars > 0
    assert part.volume.lines > 0
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
review-4.1.0 test/test_book_part.rb
review-4.0.0 test/test_book_part.rb
review-3.2.0 test/test_book_part.rb
review-3.1.0 test/test_book_part.rb
review-3.0.0 test/test_book_part.rb
review-3.0.0.rc1 test/test_book_part.rb
review-3.0.0.preview4 test/test_book_part.rb
review-3.0.0.preview3 test/test_book_part.rb
review-3.0.0.preview2 test/test_book_part.rb
review-3.0.0.preview1 test/test_book_part.rb