module Webgen::TestHelper

Public Instance Methods

assert_error_on_line(error_class, line) { || ... }

Fails if the given block does not raise error_class and the error is not on the line.

assert_log_match(reg, io = @logio)

Fails if the log string does not match the regular expression.

Uses the StringIO @logio if no other StringIO is given and resets the log string after the check.

assert_nothing_logged(io = @logio)

Fails if the log string is not empty.

Uses the StringIO @logio if no other StringIO is given.

setup_context()

Creates a Webgen::Context object that is returned and accessible via @context.

The needed website object is created using setup_website and the :chain is set to a mock node that responds to :alcn with '/test'.

setup_default_nodes(tree, klass = Webgen::Node)

Adds the following nodes (showing alcn=dest_path, title, other meta info) to the tree which has to be empty:

/
/file.en.html            'file en' sort_info=3
/file.en.html#frag       'frag'
/file.en.html#nested     'fragnested' routing_path="/routed.html"
/file.de.html            'file de' sort_info=5
/file.de.html#frag       'frag'
/other.html              'other'
/other.en.html           'other en'
/german.de.html          'german' dest_path='/german.other.html'
/dir/                    'dir'
/dir/subfile.html        'subfile'
/dir/subfile.html#frag   'frag'
/dir/dir/                'dir'
/dir/dir/file.html       'file'
/dir2/                   'dir2' proxy_path='index.html'
/dir2/index.en.html      'index en' routed_title='routed en' link_attrs={'class' => 'help'}
/dir2/index.de.html      'index de' routed_title='routed de'
setup_tag_template(root)

Creates and returns a RenderNode /tag.template using the default tag template.

setup_website(config = {})

Creates a basic stub website that is accessible via @website with the following methods:

@website.config

The given config object or {} if none specified

@website.directory

Set to a non-existent temporary directory

@website.tmpdir

Set to @website.directory/tmp

@website.ext

OpenStruct instance. The accessor item_tracker is set to an object that responds to add.

@website.blackboard

A Webgen::Blackboard instance

@website.logger

Webgen::Logger instance with a StringIO as target. The StringIO target is also available via @logio.

@website.tree

Webgen::Tree instance