Sha256: d0c6ef2388f28a6b547b0f5821e777d61ce488870026469438fe2da24023f7ce

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

require 'webgen/test'
require 'rbconfig'

class ExecuteCommandTagTest < Webgen::TagTestCase

  plugin_files [
                'webgen/plugins/coreplugins/resourcemanager.rb',
                'webgen/plugins/tags/executecommand.rb',
               ]
  plugin_to_test 'Tag/ExecuteCommand'


  def test_process_tag
    testtext = "a\"b\""
    set_config( 'command'=>echo_cmd( testtext ), 'processOutput'=>false, 'escapeHTML'=>false )
    assert_equal( testtext, @plugin.process_tag( 'executecommand', nil ).chomp.strip )
    assert_equal( false, @plugin.process_output? )

    set_config( 'command'=>echo_cmd( testtext ), 'processOutput'=>true, 'escapeHTML'=>false )
    assert_equal( testtext, @plugin.process_tag( 'executecommand', nil ).chomp.strip )
    assert_equal( true, @plugin.process_output? )

    set_config( 'command'=>echo_cmd( testtext ), 'processOutput'=>true, 'escapeHTML'=>true )
    assert_equal( 'a&quot;b&quot;', @plugin.process_tag( 'executecommand', nil ).chomp.strip )

    set_config( 'command'=>echo_cmd( testtext ), 'processOutput'=>true, 'escapeHTML'=>true, 'highlight'=>'ruby' )
    assert_kind_of( String, @plugin.process_tag( 'executecommand', nil ) )

    set_config( 'command'=>"invalid_echo_command -n '#{testtext}'", 'processOutput'=>true, 'escapeHTML'=>true )
    assert_equal( '', @plugin.process_tag( 'executecommand', nil ).chomp.strip )
  end

  def echo_cmd( data )
    (Config::CONFIG['arch'].include?( 'mswin32' ) ?  "echo #{data}" : "echo '#{data}'")
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
webgen-0.4.0 test/unittests/tc_tags_executecommand.rb
webgen-0.4.1 test/unittests/tc_tags_executecommand.rb
webgen-0.4.2 test/unittests/tc_tags_executecommand.rb
webgen-0.4.3 test/unittests/tc_tags_executecommand.rb
webgen-0.4.5 test/unittests/tc_tags_executecommand.rb
webgen-0.4.4 test/unittests/tc_tags_executecommand.rb
webgen-0.4.7 test/unittests/tc_tags_executecommand.rb
webgen-0.4.6 test/unittests/tc_tags_executecommand.rb