Sha256: 8df084b1b9f9a8dfc14f68d98f5a0b18e5861a06d897c118dcbb13611dc4861c
Contents?: true
Size: 1.48 KB
Versions: 15
Compression:
Stored size: 1.48 KB
Contents
# -*- encoding: utf-8 -*- require 'webgen/test_helper' require 'webgen/task/create_website' require 'fileutils' require 'ostruct' class TestTaskCreateWebsite < Minitest::Test 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) if Dir.exist?(@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'))) assert(File.directory?(File.join(@website.directory, 'src'))) assert(File.file?(File.join(@website.directory, 'webgen.config'))) end end end
Version data entries
15 entries across 15 versions & 1 rubygems