Sha256: 2ee2f653d7ce972664645241834b055c9474594ac876c0d67856b65bf7b5b910
Contents?: true
Size: 1.94 KB
Versions: 2
Compression:
Stored size: 1.94 KB
Contents
require 'fileutils' require 'webgen/test' require 'webgen/node' class IncludeFileTagTest < Webgen::TagTestCase plugin_files [ 'webgen/plugins/coreplugins/resourcemanager.rb', 'webgen/plugins/tags/includefile.rb', ] plugin_to_test 'Tag/IncludeFile' def test_process_tag parent = Node.new( nil, 'dir/' ) parent.node_info[:src] = fixture_path node = Node. new( parent, 'testfile' ) node.node_info[:src] = fixture_path( 'testfile' ) content = File.read( fixture_path( 'testfile' ) ) set_config( 'filename'=>"testfile", 'processOutput'=>false, 'escapeHTML'=>false ) assert_equal( content, @plugin.process_tag( 'includeFile', [node] ) ) assert_equal( false, @plugin.process_output? ) set_config( 'filename'=>"testfile", 'processOutput'=>true, 'escapeHTML'=>false ) assert_equal( content, @plugin.process_tag( 'includeFile', [node] ) ) assert_equal( true, @plugin.process_output? ) set_config( 'filename'=>"testfile", 'processOutput'=>true, 'escapeHTML'=>true ) assert_equal( CGI::escapeHTML(content), @plugin.process_tag( 'includeFile', [node] ) ) set_config( 'filename'=>"testfile", 'processOutput'=>true, 'escapeHTML'=>false, 'highlight'=>'html' ) assert_kind_of( String, @plugin.process_tag( 'includeFile', [node] ) ) set_config( 'filename'=>"invalidfile", 'processOutput'=>true, 'escapeHTML'=>true ) assert_equal( '', @plugin.process_tag( 'includeFile', [node] ) ) # test absolute file name begin name = "webgen-test-file-#{$$}.txt" full_name = File.join( '/tmp', name ) FileUtils.mkdir_p( '/tmp' ) File.open( full_name, 'w+' ) {|f| f.write('hallo')} set_config( 'filename'=>full_name, 'processOutput'=>true, 'escapeHTML'=>true ) assert_equal( 'hallo', @plugin.process_tag( 'includeFile', [node] ) ) ensure FileUtils.rm( full_name ) rescue '' FileUtils.rmdir( '/tmp' ) rescue '' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
webgen-0.4.1 | test/unittests/tc_tags_includefile.rb |
webgen-0.4.0 | test/unittests/tc_tags_includefile.rb |