summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2013-12-04 23:40:24 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2013-12-04 23:40:24 -0800
commit125a444bbd7c9e8cde2d29783ba232b5389760a0 (patch)
treed28722fece29470a063155a83c5f6a5bdcfbcafe /spec
parentb61380c4f14f0df8ceffec965c602e9e3a523173 (diff)
downloadffi-yajl-125a444bbd7c9e8cde2d29783ba232b5389760a0.tar.gz
fix #to_json on base classes
Diffstat (limited to 'spec')
-rw-r--r--spec/ffi_yajl/json_gem_spec.rb36
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/ffi_yajl/json_gem_spec.rb b/spec/ffi_yajl/json_gem_spec.rb
index be35331..5bbf3bd 100644
--- a/spec/ffi_yajl/json_gem_spec.rb
+++ b/spec/ffi_yajl/json_gem_spec.rb
@@ -183,11 +183,9 @@ describe "JSON Gem Compat API" do
shared_examples_for "handling utf8 correctly" do
it "should encode the content correctly" do
- pending "FIXME"
expect(utf8.to_json).to eq(json)
end
it "should parse the content correctly" do
- pending "FIXME"
expect(JSON.parse(json)).to eq(utf8)
end
end
@@ -236,6 +234,40 @@ describe "JSON Gem Compat API" do
end
+ context "when encoding basic types with #to_json" do
+ it "Array#to_json should work" do
+ expect([ "a", "b", "c" ].to_json).to eq(%Q{["a","b","c"]})
+ end
+
+ it "Hash#to_json should work" do
+ expect({"a"=>"b"}.to_json).to eq(%Q{{"a":"b"}})
+ end
+
+ it "Fixnum#to_json should work" do
+ expect(1.to_json).to eq("1")
+ end
+
+ it "Float#to_json should work" do
+ expect(1.1.to_json).to eq("1.1")
+ end
+
+ it "String#to_json should work" do
+ expect("foo".to_json).to eq(%Q{"foo"})
+ end
+
+ it "TrueClass#to_json should work" do
+ expect(true.to_json).to eq("true")
+ end
+
+ it "FalseClass#to_json should work" do
+ expect(false.to_json).to eq("false")
+ end
+
+ it "NilClass#to_json should work" do
+ expect(nil.to_json).to eq("null")
+ end
+ end
+
context "ported tests for generation" do
before(:all) do
@hash = {