Sha256: b725581950561e53f044066600a2dd4d7e4a74add2d27e68852f623b38f79bc5

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require 'test_helper'
require 'tmpdir'
require 'fileutils'
require 'yaml'
require 'rbconfig'

REVIEW_EPUBMAKER = File.expand_path('../bin/review-epubmaker', __dir__)

class EPUBMakerCmdTest < Test::Unit::TestCase
  def setup
    @tmpdir1 = Dir.mktmpdir
    @tmpdir2 = Dir.mktmpdir

    @old_rubylib = ENV['RUBYLIB']
    ENV['RUBYLIB'] = File.expand_path('lib', __dir__)
  end

  def teardown
    FileUtils.rm_rf(@tmpdir1)
    FileUtils.rm_rf(@tmpdir2)
    ENV['RUBYLIB'] = @old_rubylib
  end

  def common_buildepub(bookdir, configfile, targetepubfile)
    if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
      config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
      builddir = File.join(@tmpdir1, config['bookname'] + '-epub')
      assert !File.exist?(builddir)

      ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
      Dir.chdir(@tmpdir1) do
        system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER} #{configfile} 1>/dev/null 2>/dev/null")
      end
      assert File.exist?(File.join(@tmpdir1, targetepubfile))
    end
  end

  def test_epubmaker_cmd_samplebook
    common_buildepub('sample-book/src', 'config.yml', 'book.epub')
  end

  def test_epubmaker_cmd_syntaxbook
    common_buildepub('syntax-book', 'config.yml', 'syntax-book.epub')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
review-5.1.1 test/test_epubmaker_cmd.rb
review-5.1.0 test/test_epubmaker_cmd.rb