diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2013-12-16 14:33:44 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2013-12-16 14:33:44 -0800 |
commit | 2cefbfbdf7217537b5a638a6dd697480e47d38d5 (patch) | |
tree | eae560d3c4864c57046614276cb9b3de7e41649a /spec | |
parent | 58411ea2a9dc1e63150a3c4c496218d817d7cf9f (diff) | |
download | ffi-yajl-2cefbfbdf7217537b5a638a6dd697480e47d38d5.tar.gz |
fix encoding of fixnums and floats as keys
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ffi_yajl/encoder_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/ffi_yajl/encoder_spec.rb b/spec/ffi_yajl/encoder_spec.rb new file mode 100644 index 0000000..96dfe1a --- /dev/null +++ b/spec/ffi_yajl/encoder_spec.rb @@ -0,0 +1,24 @@ + + +require 'spec_helper' + +describe "FFI_Yajl::Encoder" do + + let(:encoder) { FFI_Yajl::Encoder.new } + + it "encodes fixnums in keys as strings" do + ruby = {1 => 2} + expect(encoder.encode(ruby)).to eq('{"1":2}') + end + + it "encodes floats in keys as strings" do + ruby = {1.1 => 2} + expect(encoder.encode(ruby)).to eq('{"1.1":2}') + end + + it "encodes bignums in keys as strings" do + ruby = {12345678901234567890 => 2} + expect(encoder.encode(ruby)).to eq('{"12345678901234567890":2}') + end +end + |