Sha256: 9013a9d8811466ffcf43bf5b27170d892b7b005b28a2dce06034ac2564aa65ba

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

require 'test/unit'
require 'helper'
require 'webgen/source'

class TestSourceFileSystemPath < Test::Unit::TestCase

  include Test::WebsiteHelper

  def test_io
    path = Webgen::Source::FileSystem::Path.new('/test.rb', __FILE__)
    assert(path.io.data =~ /TestSourceFileSystemPath/)
  end

  def test_changed?
    path = Webgen::Source::FileSystem::Path.new('/test.rb', __FILE__)
    assert(!path.changed?)
    @website.cache.instance_eval { @old_data[[:fs_path, __FILE__]] = File.mtime(__FILE__) - 1 }
    assert(path.changed?)
    @website.cache.instance_eval { @old_data[[:fs_path, __FILE__]] = File.mtime(__FILE__) + 1 }
    assert(!path.changed?)
  end

end

class TestSourceFileSystem < Test::Unit::TestCase

  include Test::WebsiteHelper

  def setup
    super
    @website = Webgen::Website.new(File.join(File.dirname(__FILE__), '..'), nil)
    @website.init
    Thread.current[:webgen_website] = @website
  end

  def test_initialize
    source = Webgen::Source::FileSystem.new('test', '**/*.page')
    assert_equal('**/*.page', source.glob)
    assert_equal(File.join(File.dirname(__FILE__), '..', 'test'), source.root)

    source = Webgen::Source::FileSystem.new('/tmp/hallo')
    assert_equal('**/*', source.glob)
    assert_equal('/tmp/hallo', source.root)

    source = Webgen::Source::FileSystem.new('c:/tmp/hallo')
    assert_equal('c:/tmp/hallo', source.root)

    source = Webgen::Source::FileSystem.new('../hallo')
    assert_equal(File.join(@website.directory, '../hallo'), source.root)
  end

  def test_paths
    source = Webgen::Source::FileSystem.new(File.join(File.dirname(__FILE__), '..', 'lib', 'webgen'), '/source/../**/*')
    assert(source.paths.length > 1)
    assert(source.paths.include?(Webgen::Path.new('/source/')))
    assert(source.paths.include?(Webgen::Path.new('/source/filesystem.rb')))
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.5.20081010 test/test_source_filesystem.rb
gettalong-webgen-0.5.5.20081012 test/test_source_filesystem.rb
gettalong-webgen-0.5.6.20081020 test/test_source_filesystem.rb
webgen-0.5.6 test/test_source_filesystem.rb