summaryrefslogtreecommitdiff
path: root/test/unit/duo.rb
blob: 05c26a5f179f092dc93384ba58e5a9d417cb5238 (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
require 'test/unit'
require 'yaml'
require 'coderay'

class DuoTest < Test::Unit::TestCase
  
  def test_two_arguments
    duo = CodeRay::Duo[:ruby, :html]
    assert_kind_of CodeRay::Scanners[:ruby], duo.scanner
    assert_kind_of CodeRay::Encoders[:html], duo.encoder
  end
  
  def test_two_hash
    duo = CodeRay::Duo[:ruby => :html]
    assert_kind_of CodeRay::Scanners[:ruby], duo.scanner
    assert_kind_of CodeRay::Encoders[:html], duo.encoder
  end
  
  def test_call
    duo = CodeRay::Duo[:python => :yml]
    yaml = [["def", :keyword],
            [" ", :space],
            ["test", :method],
            [":", :operator],
            [" ", :space],
            [:begin_group, :string],
            ["\"", :delimiter],
            ["pass", :content],
            ["\"", :delimiter],
            [:end_group, :string]]
    
    assert_equal yaml, YAML.load(duo.call('def test: "pass"'))
  end
  
end