Sha256: b132ce8027754437aa6049ba640b090a51eb83811d7ed0caa00c4cd19c4ed74f

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/test_helper')

describe TableSetter::Command do
  INSTALL_DIRECTORY = File.join "/", "tmp", "table-setter-test", "/"
  TABLE_SETTER = File.join File.dirname(__FILE__), "..", "bin", "table-setter"
  TEMPLATE_DIR = File.join TableSetter::ROOT, "template"

  def cleanup
    if File.exists? INSTALL_DIRECTORY
      FileUtils.rm_r INSTALL_DIRECTORY
    end
  end

  def install
    `#{TABLE_SETTER} install #{INSTALL_DIRECTORY}`
  end

  after do
    cleanup
  end

  before do
    install
  end

  it 'should install the configuration directory in a custom spot' do
    Dir["#{TEMPLATE_DIR}/**/*"].each do |template_file|
      assert File.exists?(template_file.gsub(TEMPLATE_DIR, INSTALL_DIRECTORY))
    end
  end

  def build_and_test(prefix="")
    prefix_option = "-p #{prefix}" if prefix.length > 0
    `#{TABLE_SETTER} build #{INSTALL_DIRECTORY} #{prefix_option}`
    Dir["#{TEMPLATE_DIR}/public/*"].each do |asset|
      corrected_path = asset.gsub(File.join(TEMPLATE_DIR, "public"), File.join(INSTALL_DIRECTORY, "out", "#{prefix}"))

      assert File.exists?(corrected_path)
    end
  end

  it 'should build the tables and install the assets in the correct folder with prefix' do
    build_and_test "test"
  end

  it 'should build the tables and install the assets in the correct folder without prefix' do
    build_and_test
  end

  it 'should build a table' do
    `#{TABLE_SETTER} build #{INSTALL_DIRECTORY}`
    assert File.exists?("#{INSTALL_DIRECTORY}/out/example/index.html")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
table_setter-0.2.12 test/table-setter-command_test.rb