# -*- encoding: utf-8 -*- require 'webgen/test_helper' require 'webgen/path_handler/virtual' require 'webgen/path' class TestPathHandlerVirtual < MiniTest::Unit::TestCase include Webgen::TestHelper class SimplePathHandler def initialize(virtual) @virtual = virtual end def create_secondary_nodes(path) path.meta_info[:virtual] = true path.meta_info['dest_path'] ||= '(.)' @virtual.create_nodes(path, {}) end end CONTENT=< '(.)', 'modified_at' => @time) nodes = @virtual.create_nodes(path, Webgen::Page.from_data(CONTENT).blocks) nodes.each {|n| assert_equal(path, n.node_info[:path])} node_de = @root.tree['/path.de.html'] node_en = @root.tree['/directory/path.en.html'] dir = @root.tree['/dir/'] refute_nil(node_de) refute_nil(dir) refute_nil(node_en) refute_nil(@root.tree['/dirnew/dirnew/dirnew/']) assert_equal('new title', node_en['title']) assert_equal(@time.tv_usec, node_en['modified_at'].tv_usec) assert(node_en['no_output']) assert_equal('My Dir', dir['title']) assert_equal('directory/other.html', node_de.route_to(node_en)) assert_equal('../path.de.html', dir.route_to(node_de)) assert_equal('../directory/other.html', dir.route_to(node_en)) assert_equal('http://www.example.com', @root.tree['/api.html'].dest_path) assert_equal('http://www.example.com', @root.tree['/path.de.html'].route_to(@root.tree['/api.html'])) end end