Sha256: 5c7e7de7d05d10b3b7321f5b393bc4f4a627f206cff6e1c7227011e1bb945971
Contents?: true
Size: 1.53 KB
Versions: 12
Compression:
Stored size: 1.53 KB
Contents
require 'test/unit' require 'webgen/tree' require 'webgen/page' require 'webgen/contentprocessor' class TestContentProcessorBlocks < Test::Unit::TestCase def test_process obj = Webgen::ContentProcessor::Blocks.new root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/') node = Webgen::Node.new(root, 'test', 'test') node.node_info[:page] = Webgen::Page.from_data("--- name:content\ndata") template = Webgen::Node.new(root, 'template', 'template') template.node_info[:page] = Webgen::Page.from_data("--- name:content pipeline:blocks\nbefore<webgen:block name='content' />after") processors = { 'blocks' => obj } context = Webgen::ContentProcessor::Context.new(:chain => [node], :processors => processors) context.content = '<webgen:block name="content" /><webgen:block name="content" chain="template;test" />' obj.call(context) assert_equal('databeforedataafter', context.content) assert_equal(Set.new([node.absolute_lcn, template.absolute_lcn]), node.node_info[:used_nodes]) context.content = '<webgen:block name="nothing"/>' assert_raise(RuntimeError) { obj.call(context) } context.content = '<webgen:block name="content" chain="invalid" /><webgen:block name="content" />' node.node_info[:used_nodes] = Set.new context[:chain] = [node, template, node] obj.call(context) assert_equal('<webgen:block name="content" chain="invalid" />beforedataafter', context.content) assert_equal(Set.new([template.absolute_lcn, node.absolute_lcn]), node.node_info[:used_nodes]) end end
Version data entries
12 entries across 12 versions & 2 rubygems