Sha256: 9aa9b999ffcb0bfbfe5df8542f8832cf9c938cc365bd547910f6de6a4149d86c

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

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

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

class TestContentProcessorErb < Test::Unit::TestCase

  include Test::WebgenAssertions

  def test_call
    obj = Webgen::ContentProcessor::Erb.new
    root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
    node = Webgen::Node.new(root, 'test', 'test')
    content = "<%= context[:doit] %>6\n<%= context.ref_node.alcn %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% context.website %>"
    context = Webgen::Context.new(:content => content, :doit => 'hallo',
                                                    :chain => [node])
    obj.call(context)
    assert_equal("hallo6\n/test\n/test\n/test", context.content)

    context.content = "\n<%= 5* %>"
    assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

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