Sha256: f2d125d57b17db2ea24238f01a9bd0e66549ffdf6a8c948291c7ba57f16b5e6e

Contents?: true

Size: 1.81 KB

Versions: 6

Compression:

Stored size: 1.81 KB

Contents

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

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

6 entries across 6 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.4.20080929 test/test_source_filesystem.rb
gettalong-webgen-0.5.5.20081001 test/test_source_filesystem.rb
webgen-0.5.3 test/test_source_filesystem.rb
webgen-0.5.2 test/test_source_filesystem.rb
webgen-0.5.4 test/test_source_filesystem.rb
webgen-0.5.5 test/test_source_filesystem.rb