Sha256: 5e6dd9512a6236f191168efe2c75d130a78cef64d0ad935fe56a71b7546b2e0f

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require 'test/unit'
require 'test/helper'
require 'webgen/page'
require 'webgen/tree'
require 'webgen/contentprocessor'

class TestContentProcessorFragments < Test::Unit::TestCase

  include Test::WebsiteHelper

  def test_process
    Webgen::SourceHandler::Main.new
    @website.blackboard.del_service(:source_paths)
    @website.blackboard.add_service(:source_paths) { Hash.new(path_with_meta_info('/')) }

    obj = Webgen::ContentProcessor::Fragments.new
    root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
    root.node_info[:src] = '/'
    processors = { 'fragments' => obj }

    context = Webgen::ContentProcessor::Context.new(:chain => [root], :processors => processors)
    context.content = '<h1 id="test">Test</h1><h1>Test2</h1>'
    obj.call(context)
    assert(root.tree['/#test'])
    assert_equal(3, root.tree.node_access[:alcn].length)
    root.tree.delete_node('/#test')

    context[:block] = Webgen::Block.new('content', '', {})
    obj.call(context)
    assert(root.tree['/#test'])
    assert_equal(3, root.tree.node_access[:alcn].length)
    root.tree.delete_node('/#test')

    context[:block] = Webgen::Block.new('other', '', {})
    obj.call(context)
    assert(!root.tree['/#test'])
    assert_equal(2, root.tree.node_access[:alcn].length)
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

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