28 lines
1.2 KiB
Ruby
28 lines
1.2 KiB
Ruby
require File.dirname(__FILE__) + '/helper'
|
|
|
|
class RoccoLanguageDetection < Test::Unit::TestCase
|
|
def test_basic_detection
|
|
r = Rocco.new( 'filename.py' ) { "" }
|
|
if r.pygmentize?
|
|
assert_equal "python", r.detect_language(), "`detect_language()` should return the correct language"
|
|
assert_equal "python", r.options[:language], "`@options[:language]` should be set to the correct language"
|
|
end
|
|
end
|
|
|
|
def test_fallback_default
|
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" }
|
|
if r.pygmentize?
|
|
assert_equal "text", r.detect_language(), "`detect_language()` should return `text` when nothing else is detected"
|
|
assert_equal "ruby", r.options[:language], "`@options[:language]` should be set to `ruby` when nothing else is detected"
|
|
end
|
|
end
|
|
|
|
def test_fallback_user
|
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "c" } ) { "" }
|
|
if r.pygmentize?
|
|
assert_equal "text", r.detect_language(), "`detect_language()` should return `text` nothing else is detected"
|
|
assert_equal "c", r.options[:language], "`@options[:language]` should be set to the user's setting when nothing else is detected"
|
|
end
|
|
end
|
|
end
|