mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Print out samples db diffs
This commit is contained in:
		| @@ -1,4 +1,6 @@ | ||||
| require 'linguist/samples' | ||||
| require 'tempfile' | ||||
| require 'yajl' | ||||
|  | ||||
| require 'test/unit' | ||||
|  | ||||
| @@ -12,6 +14,19 @@ class TestSamples < Test::Unit::TestCase | ||||
|     # Just warn, it shouldn't scare people off by breaking the build. | ||||
|     if serialized['md5'] != latest['md5'] | ||||
|       warn "Samples database is out of date. Run `bundle exec rake samples`." | ||||
|  | ||||
|       expected = Tempfile.new('expected.json') | ||||
|       expected.write Yajl::Encoder.encode(serialized, :pretty => true) | ||||
|       expected.close | ||||
|  | ||||
|       actual = Tempfile.new('actual.json') | ||||
|       actual.write Yajl::Encoder.encode(latest, :pretty => true) | ||||
|       actual.close | ||||
|  | ||||
|       warn `diff #{expected.path} #{actual.path}` | ||||
|  | ||||
|       expected.unlink | ||||
|       actual.unlink | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user