Sha256: b641fddf2ff6e03219a9503cf4c48cb25bfd566c2a5481f35b3d12e1a813ac33

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

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

require 'test/unit'
require 'webgen/website'
require 'tmpdir'
require 'fileutils'

class TestSourceHandlerMain < Test::Unit::TestCase

  def test_output_deletion
    dir = nil
    setup_task = lambda do
      dir = File.join(Dir.tmpdir, 'webgen-' + Process.pid.to_s)
      FileUtils.rm_rf(dir)
      FileUtils.mkdir_p(dir)
      FileUtils.mkdir_p(File.join(dir, 'src'))
      FileUtils.touch(File.join(dir, 'src', 'test.jpg'))
    end

    setup_task.call
    ws = Webgen::Website.new(dir, nil) {|c| c['output.do_deletion'] = false }
    assert_equal(:success, ws.render)
    assert(File.exists?(File.join(dir, 'out', 'test.jpg')))
    FileUtils.rm_rf(File.join(dir, 'src', 'test.jpg'))
    assert_equal(:success, ws.render)
    assert(File.exists?(File.join(dir, 'out', 'test.jpg')))

    setup_task.call
    ws = Webgen::Website.new(dir, nil) {|c| c['output.do_deletion'] = true }
    assert_equal(:success, ws.render)
    assert(File.exists?(File.join(dir, 'out', 'test.jpg')))
    FileUtils.rm_rf(File.join(dir, 'src', 'test.jpg'))
    assert_equal(:success, ws.render)
    assert(!File.exists?(File.join(dir, 'out', 'test.jpg')))
  ensure
    FileUtils.rm_rf(dir)
  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.9.20090620 test/test_sourcehandler_main.rb
gettalong-webgen-0.5.9.20090626 test/test_sourcehandler_main.rb
webgen-0.5.17 test/test_sourcehandler_main.rb
webgen-0.5.15 test/test_sourcehandler_main.rb
webgen-0.5.14 test/test_sourcehandler_main.rb
webgen-0.5.13 test/test_sourcehandler_main.rb
webgen-0.5.12 test/test_sourcehandler_main.rb
webgen-0.5.11 test/test_sourcehandler_main.rb
webgen-0.5.10 test/test_sourcehandler_main.rb
webgen-0.5.9 test/test_sourcehandler_main.rb