Sha256: 1d0683fcd008e1180a6befa5fff2a8b773cfea06bea367351f93cdda0bf11e5d
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
require 'test_helper' require 'tmpdir' require 'fileutils' require 'yaml' require 'rbconfig' require 'zip' REVIEW_EPUBMAKER = File.expand_path('../bin/review-epubmaker', __dir__) class EPUBMakerCmdTest < Test::Unit::TestCase def setup @tmpdir1 = Dir.mktmpdir @old_rubylib = ENV['RUBYLIB'] ENV['RUBYLIB'] = File.expand_path('lib', __dir__) end def teardown FileUtils.rm_rf(@tmpdir1) ENV['RUBYLIB'] = @old_rubylib end def common_buildepub(bookdir, configfile, targetepubfile) unless /mswin|mingw|cygwin/.match?(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 check_filesize(epubfile) unless /mswin|mingw|cygwin/.match?(RUBY_PLATFORM) Zip::File.open(epubfile) do |zio| zio.each do |entry| assert_not_equal(0, entry.size, "#{entry.name} is 0 byte.") end end end end def test_epubmaker_cmd_samplebook common_buildepub('sample-book/src', 'config.yml', 'book.epub') check_filesize(File.join(@tmpdir1, 'book.epub')) end def test_epubmaker_cmd_syntaxbook common_buildepub('syntax-book', 'config.yml', 'syntax-book.epub') check_filesize(File.join(@tmpdir1, 'syntax-book.epub')) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
review-5.6.0 | test/test_epubmaker_cmd.rb |
review-5.5.0 | test/test_epubmaker_cmd.rb |
review-5.4.0 | test/test_epubmaker_cmd.rb |