Sha256: 0cf762eb7ef976ef032a3f3a104cca236aee0c4c74ed178357da5aa862e3a83d

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

require 'test/unit'
require 'helper'
require 'webgen/sourcehandler'
require 'stringio'

class TestSourceHandlerDirectory < Test::Unit::TestCase

  include Test::WebsiteHelper

  def test_create_node
    @obj = Webgen::SourceHandler::Directory.new
    root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
    node = @obj.create_node(root, path_with_meta_info('/dir/', {:key => :value}) {StringIO.new('')})
    assert_not_nil(node)
    assert_equal(:value, node[:key])

    node.flag(:reinit)
    assert_equal(node, @obj.create_node(root, path_with_meta_info('/dir/', {:key => :other}) {StringIO.new('')}))
    assert_equal(:other, node[:key])
  end

  def test_create_directories
    @obj = Webgen::SourceHandler::Directory.new
    shm = Webgen::SourceHandler::Main.new # for using service :create_nodes
    root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
    dir = @obj.create_node(root, path_with_meta_info('/dir/'))

    assert_equal(dir, @obj.create_directories(root, '/dir/', path_with_meta_info('/test')))
    assert_equal(dir, @obj.create_directories(root, 'dir/', path_with_meta_info('/test')))
    assert_equal(dir, @obj.create_directories(root, 'dir', path_with_meta_info('/test')))

    which = @obj.create_directories(root, 'dir/under/which', path_with_meta_info('/test'))
    assert_equal(which, @obj.create_directories(root, 'dir/under/which', path_with_meta_info('/test')))
  end

  def test_content
    assert_equal('', Webgen::SourceHandler::Directory.new.content(nil))
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

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