diff options
author | murphy <murphy@rubychan.de> | 2011-02-28 23:10:25 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2011-02-28 23:10:25 +0000 |
commit | 4d8afef1c46d1db99a7c71bc71906317441a90c3 (patch) | |
tree | 18bf4a476168de72959705aae7ff6a0ef6a4d2a5 /test/unit/json_encoder.rb | |
parent | fa8b580bfcf1082ac671acde60c4205681dec1dd (diff) | |
download | coderay-4d8afef1c46d1db99a7c71bc71906317441a90c3.tar.gz |
Added lots of tests for Plugin and other helper classes.
Diffstat (limited to 'test/unit/json_encoder.rb')
-rw-r--r-- | test/unit/json_encoder.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/json_encoder.rb b/test/unit/json_encoder.rb new file mode 100644 index 0000000..4e44a64 --- /dev/null +++ b/test/unit/json_encoder.rb @@ -0,0 +1,28 @@ +require 'test/unit' +require 'coderay' + +class JSONEncoderTest < Test::Unit::TestCase + + def test_json_output + old_load_paths = $:.dup + begin + $:.delete '.' + $:.delete File.dirname(__FILE__) + json = CodeRay.scan('puts "Hello world!"', :ruby).json + assert_equal [ + {"type"=>"text", "text"=>"puts", "kind"=>"ident"}, + {"type"=>"text", "text"=>" ", "kind"=>"space"}, + {"type"=>"block", "action"=>"open", "kind"=>"string"}, + {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"}, + {"type"=>"text", "text"=>"Hello world!", "kind"=>"content"}, + {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"}, + {"type"=>"block", "action"=>"close", "kind"=>"string"}, + ], JSON.load(json) + ensure + for path in old_load_paths - $: + $: << path + end + end + end + +end
\ No newline at end of file |