summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-06-13 19:04:30 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-06-13 19:04:30 -0700
commita10bf94c402dcc5a6397567ec3811e6c305527f5 (patch)
treee84494be22a9065d02ca537758423c7d45b3675d /spec
parentc0fb725f9a1be57086c42a0ba15365585b89d112 (diff)
downloadffi-yajl-a10bf94c402dcc5a6397567ec3811e6c305527f5.tar.gz
implement symbolize_keys/names for FFI
disable some unimplemented specs
Diffstat (limited to 'spec')
-rw-r--r--spec/ffi_yajl/json_gem_spec.rb10
-rw-r--r--spec/ffi_yajl/parser_spec.rb10
2 files changed, 12 insertions, 8 deletions
diff --git a/spec/ffi_yajl/json_gem_spec.rb b/spec/ffi_yajl/json_gem_spec.rb
index 0a910fb..8da827a 100644
--- a/spec/ffi_yajl/json_gem_spec.rb
+++ b/spec/ffi_yajl/json_gem_spec.rb
@@ -86,42 +86,36 @@ describe "JSON Gem Compat API" do
end
context "when setting symbolize_keys via JSON.default_options" do
- before(:all) { @saved_default = JSON.default_options[:symbolize_keys] }
- after(:all) { JSON.default_options[:symbolize_keys] = @saved_default }
+ after(:each) { JSON.default_options[:symbolize_keys] = false }
it "the default behavior should be to not symbolize keys" do
expect(JSON.parse('{"foo": 1234}')).to eq( "foo" => 1234 )
end
it "changing the default_options should change the behavior to true" do
- skip("implement symbolize keys")
JSON.default_options[:symbolize_keys] = true
expect(JSON.parse('{"foo": 1234}')).to eq( :foo => 1234 )
end
end
context "when setting symbolize_names via JSON.default_options" do
- before(:all) { @saved_default = JSON.default_options[:symbolize_names] }
- after(:all) { JSON.default_options[:symbolize_names] = @saved_default }
+ after { JSON.default_options.delete(:symbolize_names)}
it "the default behavior should be to not symbolize keys" do
expect(JSON.parse('{"foo": 1234}')).to eq( "foo" => 1234 )
end
it "changing the default_options should change the behavior to true" do
- skip("implement symbolize keys")
JSON.default_options[:symbolize_names] = true
expect(JSON.parse('{"foo": 1234}')).to eq( :foo => 1234 )
end
end
it "should support passing symbolize_names to JSON.parse" do
- skip("implement symbolize keys")
expect(JSON.parse('{"foo": 1234}', :symbolize_names => true)).to eq( :foo => 1234 )
end
it "should support passing symbolize_keys to JSON.parse" do
- skip("implement symbolize keys")
expect(JSON.parse('{"foo": 1234}', :symbolize_keys => true)).to eq( :foo => 1234 )
end
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb
index 721209d..4e1f138 100644
--- a/spec/ffi_yajl/parser_spec.rb
+++ b/spec/ffi_yajl/parser_spec.rb
@@ -21,6 +21,7 @@ describe "FFI_Yajl::Parser" do
let(:options) { { :allow_comments => false } }
it "should not parse" do
+ skip "implement :allow_comments"
expect{parser}.to raise_error(FFI_Yajl::ParseError)
end
end
@@ -29,6 +30,7 @@ describe "FFI_Yajl::Parser" do
let(:options) { { :allow_comments => true } }
it "should parse" do
+ skip "implement :allow_comments"
expect(parser).to eq({}) # FIXME
end
end
@@ -41,6 +43,7 @@ describe "FFI_Yajl::Parser" do
let(:options) { { :check_utf8 => true } }
it "should not parse" do
+ skip "implement :check_utf8"
expect{parser}.to raise_error(FFI_Yajl::ParseError)
end
end
@@ -49,6 +52,7 @@ describe "FFI_Yajl::Parser" do
let(:options) { { :check_utf8 => false } }
it "should parse" do
+ skip "implement :check_utf8"
expect(parser).to eq({}) # FIXME
end
end
@@ -58,6 +62,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { StringIO.new('{"key": 1234}') }
it "should parse" do
+ skip "handle StringIOs"
expect(parser).to eq({"key" => 1234})
end
end
@@ -79,6 +84,7 @@ describe "FFI_Yajl::Parser" do
context "when passing a block" do
it "should parse correctly" do
+ skip "handle blocks"
output = nil
parser do |obj|
output = obj
@@ -86,6 +92,10 @@ describe "FFI_Yajl::Parser" do
expect(output).to eq({"key" => 1234})
end
end
+ end
+
+ context "when parsing a JSON hash with only strings" do
+ let(:json) { '{"key": "value"}' }
if RUBY_VERSION.to_f >= 1.9
context "when Encoding.default_internal is nil" do