Sample returns simple hash objects

This commit is contained in:
Joshua Peek
2012-07-20 16:17:37 -05:00
parent ee0ffa0516
commit eb2c07e511
3 changed files with 19 additions and 45 deletions

View File

@@ -276,8 +276,9 @@ class TestBlob < Test::Unit::TestCase
def test_language
Sample.each do |sample|
blob = blob(sample.path)
assert_equal sample.language, blob.language, blob.name
blob = blob(sample[:path])
language = Linguist::Language.find_by_alias(sample[:language])
assert_equal language, blob.language, blob.name
end
end

View File

@@ -69,14 +69,15 @@ class TestClassifier < Test::Unit::TestCase
def test_classify_ambiguous_languages
Sample.each do |sample|
next unless sample.language.overrides.any?
language = Linguist::Language.find_by_alias(sample[:language])
next unless language.overrides.any?
extname = File.extname(sample.path)
extname = File.extname(sample[:path])
languages = Language.all.select { |l| l.extensions.include?(extname) }.map(&:name)
next unless languages.length > 1
results = Classifier.instance.classify(sample.data, languages)
assert_equal sample.language.name, results.first[0], "#{sample.path}\n#{results.inspect}"
results = Classifier.instance.classify(File.read(sample[:path]), languages)
assert_equal language.name, results.first[0], "#{sample[:path]}\n#{results.inspect}"
end
end
end