Sha256: 018934526f650d33c601ade3e77bb908d2117aed338fe1f52dbcffddd31191ad

Contents?: true

Size: 1.2 KB

Versions: 12

Compression:

Stored size: 1.2 KB

Contents

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

require 'webgen/test_helper'

class TestErubis < Minitest::Test

  include Webgen::TestHelper

  def test_static_call
    require 'webgen/content_processor/erubis' rescue skip('Library erubis not installed')
    setup_context
    @website.config.merge!('content_processor.erubis.options' => {}, 'content_processor.erubis.use_pi' => false)
    cp = Webgen::ContentProcessor::Erubis

    @context.content = "<%= context[:doit] %>6\n<%= h(context.ref_node.alcn) %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% context.website %>"
    assert_equal("hallo6\n/test\n/test\n/test", cp.call(@context).content)

    @context.content = "\n<%= 5* %>"
    assert_error_on_line(SyntaxError, 2) { cp.call(@context) }

    @context.content = "\n\n<% unknown %>"
    assert_error_on_line(NameError, 3) { cp.call(@context) }

    @website.config['content_processor.erubis.options'][:trim] = true
    @context.content = "<% for i in [1] %>\n<%= i %>\n<% end %>"
    assert_equal("1\n", cp.call(@context).content)

    @website.config['content_processor.erubis.use_pi'] = true
    @context.content = "<?rb for i in [1] ?>\n@{i}@\n<?rb end ?>"
    assert_equal("1\n", cp.call(@context).content)
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
webgen-1.7.3 test/webgen/content_processor/test_erubis.rb
webgen-1.7.2 test/webgen/content_processor/test_erubis.rb
webgen-1.7.1 test/webgen/content_processor/test_erubis.rb
webgen-1.7.0 test/webgen/content_processor/test_erubis.rb
webgen-1.6.0 test/webgen/content_processor/test_erubis.rb
webgen-1.5.2 test/webgen/content_processor/test_erubis.rb
webgen-1.5.1 test/webgen/content_processor/test_erubis.rb
webgen-1.5.0 test/webgen/content_processor/test_erubis.rb
webgen-1.4.1 test/webgen/content_processor/test_erubis.rb
webgen-1.4.0 test/webgen/content_processor/test_erubis.rb
webgen-1.3.0 test/webgen/content_processor/test_erubis.rb
webgen-1.2.1 test/webgen/content_processor/test_erubis.rb