mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Add sample gathering class
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| require 'linguist/file_blob' | ||||
| require 'linguist/sample' | ||||
|  | ||||
| require 'test/unit' | ||||
| require 'mime/types' | ||||
| @@ -24,23 +25,6 @@ class TestBlob < Test::Unit::TestCase | ||||
|     blob | ||||
|   end | ||||
|  | ||||
|   def each_language_fixture | ||||
|     Dir["#{fixtures_path}/*"].each do |path| | ||||
|       name = File.basename(path) | ||||
|  | ||||
|       if name == 'text' || name == 'binary' | ||||
|         next | ||||
|       else | ||||
|         assert language = Language.find_by_alias(name), "No language alias for #{name.inspect}" | ||||
|       end | ||||
|  | ||||
|       Dir.entries(path).each do |filename| | ||||
|         next if filename == '.' || filename == '..' | ||||
|         yield language, blob(File.join(path, filename)) | ||||
|       end | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   def test_name | ||||
|     assert_equal "foo.rb", blob("foo.rb").name | ||||
|   end | ||||
| @@ -287,9 +271,9 @@ class TestBlob < Test::Unit::TestCase | ||||
|   end | ||||
|  | ||||
|   def test_language | ||||
|     # Drop any files under test/fixtures/LANGUAGE | ||||
|     each_language_fixture do |language, blob| | ||||
|       assert_equal language, blob.language, blob.name | ||||
|     Sample.each do |sample| | ||||
|       blob = blob(sample.path) | ||||
|       assert_equal sample.language, blob.language, blob.name | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user