Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:089bb90e8da1ad65f6c2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
/Users/erik/.rbenv/versions/1.9.3-p125/bin/ruby -S rspec ./spec/multi_json_spec.rb
NSJSONSerialization is exclusively available for MacRuby only.
......................FFF....FF...............................
 
Failures:
 
1) MultiJson oj.decode properly decodes valid JSON in StringIOs
Failure/Error: MultiJson.decode(json).should == { 'abc' => 'def' }
TypeError:
wrong argument type StringIO (expected String)
# ./lib/multi_json/engines/oj.rb:10:in `load'
# ./lib/multi_json/engines/oj.rb:10:in `decode'
# ./lib/multi_json.rb:81:in `decode'
# ./spec/multi_json_spec.rb:160:in `block (5 levels) in <top (required)>'
 
2) MultiJson oj.decode allows for symbolization of keys
Failure/Error: MultiJson.decode(example, :symbolize_keys => true).should == expected
expected: {:abc=>{:def=>"hgi"}}
got: {"abc"=>{"def"=>"hgi"}} (using ==)
Diff:
@@ -1,2 +1,2 @@
-:abc => {:def=>"hgi"}
+"abc" => {"def"=>"hgi"}
# ./spec/multi_json_spec.rb:178:in `block (6 levels) in <top (required)>'
# ./spec/multi_json_spec.rb:168:in `each'
# ./spec/multi_json_spec.rb:168:in `block (5 levels) in <top (required)>'
 
3) MultiJson oj.decode stringifys symbol keys when encoding
Failure/Error: MultiJson.decode(encoded_json).should == { "a" => 1, "b" => { "c" => 2 } }
expected: {"a"=>1, "b"=>{"c"=>2}}
got: {:a=>1, :b=>{:c=>2}} (using ==)
Diff:
@@ -1,3 +1,3 @@
-"a" => 1,
-"b" => {"c"=>2}
+:a => 1,
+:b => {:c=>2}
# ./spec/multi_json_spec.rb:155:in `block (5 levels) in <top (required)>'
 
4) MultiJson oj.encode encodes symbol keys as strings
Failure/Error: MultiJson.decode(encoded_json).should == expected
expected: {"foo"=>{"bar"=>"baz"}}
got: {:foo=>{:bar=>"baz"}} (using ==)
Diff:
@@ -1,2 +1,2 @@
-"foo" => {"bar"=>"baz"}
+:foo => {:bar=>"baz"}
# ./spec/multi_json_spec.rb:104:in `block (6 levels) in <top (required)>'
# ./spec/multi_json_spec.rb:93:in `each'
# ./spec/multi_json_spec.rb:93:in `block (5 levels) in <top (required)>'
 
5) MultiJson oj.encode encodes custom objects which implement as_json
Failure/Error: MultiJson.encode(TimeWithZone.new).should == "\"2005-02-01T15:15:10Z\""
expected: "\"2005-02-01T15:15:10Z\""
got: "{\"^o\":\"TimeWithZone}" (using ==)
# ./spec/multi_json_spec.rb:129:in `block (5 levels) in <top (required)>'
 
Finished in 0.06524 seconds
62 examples, 5 failures
 
Failed examples:
 
rspec ./spec/multi_json_spec.rb:158 # MultiJson oj.decode properly decodes valid JSON in StringIOs
rspec ./spec/multi_json_spec.rb:163 # MultiJson oj.decode allows for symbolization of keys
rspec ./spec/multi_json_spec.rb:153 # MultiJson oj.decode stringifys symbol keys when encoding
rspec ./spec/multi_json_spec.rb:88 # MultiJson oj.encode encodes symbol keys as strings
rspec ./spec/multi_json_spec.rb:128 # MultiJson oj.encode encodes custom objects which implement as_json
 
Randomized with seed 14770
 
Coverage report generated for RSpec to /Users/erik/Projects/multi_json/coverage. 240 / 377 LOC (63.66%) covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.