Sha256: 63fbe383352f8739d587bbce32c98cf093f7ed13612a4d6c9bcf4007dbf5b631

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

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

REVIEW_IDGXMLMAKER = File.expand_path('../bin/review-idgxmlmaker', __dir__)

class IDGXMLMakerCmdTest < 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_buildidgxml(bookdir, configfile, targetfile, option)
    unless /mswin|mingw|cygwin/.match?(RUBY_PLATFORM)
      config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
      builddir = File.join(@tmpdir1, config['bookname'] + '-idgxml')
      assert !File.exist?(builddir)

      ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
      Dir.chdir(@tmpdir1) do
        _o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_IDGXMLMAKER} #{option} #{configfile}")
        if defined?(ReVIEW::TTYLogger)
          assert_match(/SUCCESS/, e)
        else
          assert_equal '', e
        end
        assert s.success?
      end
      assert File.exist?(File.join(@tmpdir1, targetfile))
    end
  end

  def test_idgxmlmaker_cmd_samplebook
    common_buildidgxml('sample-book/src', 'config.yml', 'book-idgxml/ch01.xml', nil)
  end

  def test_idgxmlmaker_cmd_syntaxbook
    common_buildidgxml('syntax-book', 'config.yml', 'syntax-book-idgxml/ch01.xml', nil)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
review-5.6.0 test/test_idgxmlmaker_cmd.rb
review-5.5.0 test/test_idgxmlmaker_cmd.rb
review-5.4.0 test/test_idgxmlmaker_cmd.rb