aboutsummaryrefslogtreecommitdiff
path: root/test/test_samples.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2012-09-24 10:07:08 -0500
committerJoshua Peek <josh@joshpeek.com>2012-09-24 10:07:08 -0500
commit10e875e899fa97a6d51bbaa3938e11eca7b24079 (patch)
tree26c4529c881dc5072ca6604d18eb16e52393cc31 /test/test_samples.rb
parentd24e5c938e285a999e5d3649ac1b450d7c581003 (diff)
Print out samples db diffs
Diffstat (limited to 'test/test_samples.rb')
-rw-r--r--test/test_samples.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_samples.rb b/test/test_samples.rb
index e969909..fb9da10 100644
--- a/test/test_samples.rb
+++ b/test/test_samples.rb
@@ -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