summaryrefslogtreecommitdiff
path: root/test/executable/suite.rb
blob: 0c5de27ffec6df73e68a08e30cb7de39739a19a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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' + 'coderay'
  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_nothing_raised { coderay('') }
  end
  
  VERSION_PATTERN = /CodeRay \d\.\d\.\d/
  def test_version
    assert_match(VERSION_PATTERN, coderay(''))
    # assert_match(VERSION_PATTERN, coderay('--version'))
    # assert_match(VERSION_PATTERN, coderay('-v'))
  end
  
  HELP_PATTERN = /Usage:/
  def test_help
    assert_match(HELP_PATTERN, coderay(''))
    # assert_match(HELP_PATTERN, coderay('--help'))
    # assert_match(HELP_PATTERN, coderay('-h'))
  end
  
end