From e1fc595c0ef72537b2a01ff8591f83d4b077241e Mon Sep 17 00:00:00 2001 From: murphy Date: Fri, 11 Jun 2010 10:49:56 +0000 Subject: Added coderay executable tests. --- test/executable/suite.rb | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 test/executable/suite.rb (limited to 'test') diff --git a/test/executable/suite.rb b/test/executable/suite.rb new file mode 100755 index 0000000..da84fb0 --- /dev/null +++ b/test/executable/suite.rb @@ -0,0 +1,45 @@ +require 'test/unit' +require 'pathname' + +MYDIR = File.dirname(__FILE__) + +$:.unshift 'lib' +require 'coderay' +puts "Running basic CodeRay #{CodeRay::VERSION} executable tests..." + +class TestCodeRayExecutable < Test::Unit::TestCase + + ruby = `ps -c #$$`[/\w+\Z/] + ruby = 'jruby' if ruby == 'java' + + ROOT_DIR = Pathname.new(File.dirname(__FILE__)) + '..' + '..' + EXECUTABLE = ROOT_DIR + 'bin' + 'coderay2' + EXE_COMMAND = '%s -wI%s %s'% [ + ruby, # calling Ruby process command + ROOT_DIR + 'lib', # library dir + EXECUTABLE + ] + + def coderay args + command = "#{EXE_COMMAND} #{args}" + # puts command + `#{command}` + end + + def test_simple + assert_equal '', coderay('') + end + + VERSION_PATTERN = /\ACodeRay \d\.\d\.\d\n\z/ + def test_version + assert_match(VERSION_PATTERN, coderay('--version')) + assert_match(VERSION_PATTERN, coderay('-v')) + end + + HELP_PATTERN = /Usage:/ + def test_help + assert_match(HELP_PATTERN, coderay('--help')) + assert_match(HELP_PATTERN, coderay('-h')) + end + +end \ No newline at end of file -- cgit v1.2.1