Sha256: acecc3c1c577c97cfe812133d2402a4aa23f2768e573880768ededda926af39e

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

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

require 'webgen/test_helper'
require 'webgen/tag/include_file'
require 'fileutils'
require 'tempfile'

class TestTagIncludeFile < Minitest::Test

  include Webgen::TestHelper

  def test_call
    setup_context

    content = "<a>This is 'a' Test</a>"
    file = Tempfile.new('webgen-test-file')
    file.write(content)
    file.close

    assert_tag_result([content, false], file.path, false, false)
    assert_tag_result([content, true], file.path, true, false)
    assert_tag_result([CGI::escapeHTML(content), true], file.path, true, true)

    @context[:config]['tag.include_file.filename'] = 'invalidfile'
    assert_raises(Webgen::RenderError) { Webgen::Tag::IncludeFile.call('include_file', '', @context) }
  end

  def assert_tag_result(result, filename, process, escape)
    @context[:config] = {'tag.include_file.filename' => filename,
      'tag.include_file.process_output' => process,
      'tag.include_file.escape_html' => escape}
    assert_equal(result, Webgen::Tag::IncludeFile.call('include_file', '', @context))
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
webgen-1.7.3 test/webgen/tag/test_include_file.rb
webgen-1.7.2 test/webgen/tag/test_include_file.rb
webgen-1.7.1 test/webgen/tag/test_include_file.rb
webgen-1.7.0 test/webgen/tag/test_include_file.rb
webgen-1.6.0 test/webgen/tag/test_include_file.rb
webgen-1.5.2 test/webgen/tag/test_include_file.rb
webgen-1.5.1 test/webgen/tag/test_include_file.rb
webgen-1.5.0 test/webgen/tag/test_include_file.rb
webgen-1.4.1 test/webgen/tag/test_include_file.rb
webgen-1.4.0 test/webgen/tag/test_include_file.rb
webgen-1.3.0 test/webgen/tag/test_include_file.rb
webgen-1.2.1 test/webgen/tag/test_include_file.rb
webgen-1.2.0 test/webgen/tag/test_include_file.rb
webgen-1.1.0 test/webgen/tag/test_include_file.rb
webgen-1.0.0 test/webgen/tag/test_include_file.rb