Sha256: 0c700ebf477f3daa25657b68ea76cb2269a2c52eba63267b0e408dfa6bf74f88

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

# -*- encoding: utf-8 -*-

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

class TestContentProcessorHaml < Test::Unit::TestCase

  include Test::WebgenAssertions

  def test_call
    obj = Webgen::ContentProcessor::Haml.new
    root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
    node = Webgen::Node.new(root, 'test', 'test')
    content = "#content\n  %h1 Hallo\n  = [context.node.alcn, context.ref_node.alcn, context.dest_node.alcn, context.website, context.dest_node.alcn].join"
    context = Webgen::Context.new(:content => content,
                                                    :chain => [node])
    obj.call(context)
    assert_equal("<div id='content'>\n  <h1>Hallo</h1>\n  /test/test/test/test\n</div>\n", context.content)

    context.content = "#cont\n    % = + unknown"
    assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }

    context.content = "#cont\n  = unknown"
    assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }

    context.content = "#cont\n  = context.node.link_to(nil)"
    begin
      obj.call(context)
    rescue Webgen::RenderError => e
      assert(e.error_alcn =~ /\/lib\/webgen\/node.rb$/)
    end

    def obj.require(lib); raise LoadError; end
    assert_raise(Webgen::LoadError) { obj.call(context) }
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
webgen-0.5.17 test/test_contentprocessor_haml.rb
webgen-0.5.15 test/test_contentprocessor_haml.rb
webgen-0.5.14 test/test_contentprocessor_haml.rb
webgen-0.5.13 test/test_contentprocessor_haml.rb
webgen-0.5.12 test/test_contentprocessor_haml.rb