summaryrefslogtreecommitdiff
path: root/test/functional/basic.rb
blob: f5699ae795c10d30b6ac0d791137a0cb553b310e (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
48
49
50
51
52
53
54
55
56
57
58
require "test/unit"

require "coderay"

class Basic < Test::Unit::TestCase
  def test_version
    assert_nothing_raised do
      CodeRay::VERSION
    end
  end
  
  def test_classes_exist
    assert_nothing_raised do
      CodeRay
      CodeRay::Encoders::Encoder
      CodeRay::Encoders
      CodeRay::Scanners::Scanner
      CodeRay::Scanners
      CodeRay::Tokens
      CodeRay::TokenStream
      Plugin
      WordList
    end
  end
  
  RUBY_TEST_CODE = 'puts "Hello, World!"'
  
  def test_simple_scan
    assert_nothing_raised do
      CodeRay.scan(RUBY_TEST_CODE, :ruby)
    end
  end
  
  def test_simple_highlight
    assert_nothing_raised do
      CodeRay.scan(RUBY_TEST_CODE, :ruby).html
    end
  end
  
  def test_duo
    assert_equal(RUBY_TEST_CODE,
      CodeRay::Duo[:plain, :plain].highlight(RUBY_TEST_CODE))
  end
  
  ENCODERS_LIST = %w(
    count debug div html null page span statistic text tokens xml yaml
  )
  def test_list_of_encoders
    assert_equal(ENCODERS_LIST, CodeRay::Encoders.list)
  end

  SCANNERS_LIST = %w(
    c delphi html nitro_xhtml plaintext rhtml ruby xml
  )
  def test_list_of_encoders
    assert_equal(SCANNERS_LIST, CodeRay::Scanners.list)
  end
end