Sha256: b9bf5abc3377b4e1d5494a686ddc60d85daf8dd54447625dacc09d4024f1b96c

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

# -*- encoding: utf-8 -*-

require 'webgen/test_helper'
require 'webgen/task/create_website'
require 'fileutils'
require 'ostruct'

class TestTaskCreateWebsite < MiniTest::Unit::TestCase

  include Webgen::TestHelper

  def setup
    setup_website
    @website.ext.task = @task = Webgen::Task.new(@website)
    @task.register('CreateWebsite', :data => {:templates => {}})
  end

  def teardown
    FileUtils.remove_entry_secure(@website.directory)
  end

  def test_static_call
    @task.execute(:create_website)
    assert(File.directory?(@website.directory))
    assert(File.directory?(File.join(@website.directory, 'src')))
    assert(File.file?(File.join(@website.directory, 'webgen.config')))

    assert_raises(Webgen::Task::CreateWebsite::Error) { @task.execute(:create_website) }
  end

  def test_static_call_with_template
    Dir.mktmpdir do |tmpdir|
      Dir.mkdir(File.join(tmpdir, 'tmp'))
      File.open(File.join(tmpdir, 'tmp', 'test.erb.txt'), 'w+') {|f| f.write("<%= '#{tmpdir}' %>")}
      @task.data(:create_website)[:templates]['my_template'] = tmpdir

      @task.execute(:create_website, 'my_template')
      assert(File.directory?(@website.directory))
      assert(File.directory?(File.join(@website.directory, 'tmp')))
      assert_equal(tmpdir, File.read(File.join(@website.directory, 'tmp', 'test.txt')))
      refute(File.directory?(File.join(@website.directory, 'src')))
      refute(File.file?(File.join(@website.directory, 'webgen.config')))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webgen-1.0.0.beta2 test/webgen/task/test_create_website.rb
webgen-1.0.0.beta1 test/webgen/task/test_create_website.rb