summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-05-06 11:30:55 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-05-06 11:30:55 -0700
commit82d3f655678634fe38dff9796ec937d1a32b77fc (patch)
treee65849f6aad3ab8065fade97fbc1f298340f0a4b /spec
parent5472fa412348b37088c58def15288cf48f489681 (diff)
downloadffi-yajl-82d3f655678634fe38dff9796ec937d1a32b77fc.tar.gz
fixes SpaceInsideHashLiteralBraces
Diffstat (limited to 'spec')
-rw-r--r--spec/ffi_yajl/encoder_spec.rb12
-rw-r--r--spec/ffi_yajl/json_gem_spec.rb24
-rw-r--r--spec/ffi_yajl/parser_spec.rb18
3 files changed, 27 insertions, 27 deletions
diff --git a/spec/ffi_yajl/encoder_spec.rb b/spec/ffi_yajl/encoder_spec.rb
index a1c439e..00df5d1 100644
--- a/spec/ffi_yajl/encoder_spec.rb
+++ b/spec/ffi_yajl/encoder_spec.rb
@@ -7,17 +7,17 @@ describe "FFI_Yajl::Encoder" do
let(:encoder) { FFI_Yajl::Encoder.new }
it "encodes fixnums in keys as strings" do
- ruby = {1 => 2}
+ ruby = { 1 => 2 }
expect(encoder.encode(ruby)).to eq('{"1":2}')
end
it "encodes floats in keys as strings" do
- ruby = {1.1 => 2}
+ 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}
+ ruby = { 12345678901234567890 => 2 }
expect(encoder.encode(ruby)).to eq('{"12345678901234567890":2}')
end
@@ -37,17 +37,17 @@ describe "FFI_Yajl::Encoder" do
end
it "encodes symbols in keys as strings" do
- ruby = {:thing => 1}
+ ruby = { :thing => 1 }
expect(encoder.encode(ruby)).to eq('{"thing":1}')
end
it "encodes symbols in values as strings" do
- ruby = {"thing" => :one}
+ ruby = { "thing" => :one }
expect(encoder.encode(ruby)).to eq('{"thing":"one"}')
end
it "can encode 32-bit unsigned ints" do
- ruby = {"gid"=>4294967294}
+ ruby = { "gid"=>4294967294 }
expect(encoder.encode(ruby)).to eq('{"gid":4294967294}')
end
diff --git a/spec/ffi_yajl/json_gem_spec.rb b/spec/ffi_yajl/json_gem_spec.rb
index 25357b5..20004c5 100644
--- a/spec/ffi_yajl/json_gem_spec.rb
+++ b/spec/ffi_yajl/json_gem_spec.rb
@@ -39,7 +39,7 @@ describe "JSON Gem Compat API" do
end
it "should not mixin #to_json on a hash" do
- expect({:foo => "bar"}.respond_to?(:to_json)).to be_false
+ expect({ :foo => "bar" }.respond_to?(:to_json)).to be_false
end
it "should not mixin #to_json on a trueclass" do
@@ -90,13 +90,13 @@ describe "JSON Gem Compat API" do
after(:all) { JSON.default_options[:symbolize_keys] = @saved_default }
it "the default behavior should be to not symbolize keys" do
- expect(JSON.parse('{"foo": 1234}')).to eq({"foo" => 1234})
+ expect(JSON.parse('{"foo": 1234}')).to eq({ "foo" => 1234 })
end
it "changing the default_options should change the behavior to true" do
pending("implement symbolize keys")
JSON.default_options[:symbolize_keys] = true
- expect(JSON.parse('{"foo": 1234}')).to eq({:foo => 1234})
+ expect(JSON.parse('{"foo": 1234}')).to eq({ :foo => 1234 })
end
end
@@ -105,24 +105,24 @@ describe "JSON Gem Compat API" do
after(:all) { JSON.default_options[:symbolize_names] = @saved_default }
it "the default behavior should be to not symbolize keys" do
- expect(JSON.parse('{"foo": 1234}')).to eq({"foo" => 1234})
+ expect(JSON.parse('{"foo": 1234}')).to eq({ "foo" => 1234 })
end
it "changing the default_options should change the behavior to true" do
pending("implement symbolize keys")
JSON.default_options[:symbolize_names] = true
- expect(JSON.parse('{"foo": 1234}')).to eq({:foo => 1234})
+ expect(JSON.parse('{"foo": 1234}')).to eq({ :foo => 1234 })
end
end
it "should support passing symbolize_names to JSON.parse" do
pending("implement symbolize keys")
- expect(JSON.parse('{"foo": 1234}', :symbolize_names => true)).to eq({:foo => 1234})
+ expect(JSON.parse('{"foo": 1234}', :symbolize_names => true)).to eq({ :foo => 1234 })
end
it "should support passing symbolize_keys to JSON.parse" do
pending("implement symbolize keys")
- expect(JSON.parse('{"foo": 1234}', :symbolize_keys => true)).to eq({:foo => 1234})
+ expect(JSON.parse('{"foo": 1234}', :symbolize_keys => true)).to eq({ :foo => 1234 })
end
context "when encode arbitrary classes via their default to_json method" do
@@ -267,7 +267,7 @@ describe "JSON Gem Compat API" do
end
it "Hash#to_json should work" do
- expect({"a"=>"b"}.to_json).to eq(%Q{{"a":"b"}})
+ expect({ "a"=>"b" }.to_json).to eq(%Q{{"a":"b"}})
end
it "Fixnum#to_json should work" do
@@ -329,10 +329,10 @@ describe "JSON Gem Compat API" do
expect(JSON.parse(@json2)).to eq(JSON.parse(json))
parsed_json = JSON.parse(json)
expect(@hash).to eq(parsed_json)
- json = JSON.generate({1=>2})
+ json = JSON.generate({ 1=>2 })
expect('{"1":2}').to eql(json)
parsed_json = JSON.parse(json)
- expect({"1"=>2}).to eq(parsed_json)
+ expect({ "1"=>2 }).to eq(parsed_json)
end
it "should be able to unparse pretty" do
@@ -340,11 +340,11 @@ describe "JSON Gem Compat API" do
expect(JSON.parse(@json3)).to eq(JSON.parse(json))
parsed_json = JSON.parse(json)
expect(@hash).to eq(parsed_json)
- json = JSON.pretty_generate({1=>2})
+ json = JSON.pretty_generate({ 1=>2 })
test = "{\n \"1\": 2\n}".chomp
expect(test).to eq(json)
parsed_json = JSON.parse(json)
- expect({"1"=>2}).to eq(parsed_json)
+ expect({ "1"=>2 }).to eq(parsed_json)
end
it "JSON.generate should handle nil second argument" do
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb
index 1377f69..ee8f819 100644
--- a/spec/ffi_yajl/parser_spec.rb
+++ b/spec/ffi_yajl/parser_spec.rb
@@ -29,49 +29,49 @@ describe "FFI_Yajl::Parser" do
context "when parsing floats" do
it "parses simple floating point values" do
json = '{"foo": 3.14159265358979}'
- expect(parser.parse(json)).to eql({"foo" => 3.14159265358979})
+ expect(parser.parse(json)).to eql({ "foo" => 3.14159265358979 })
end
it "parses simple negative floating point values" do
json = '{"foo":-2.00231930436153}'
- expect(parser.parse(json)).to eql({"foo" => -2.00231930436153})
+ expect(parser.parse(json)).to eql({ "foo" => -2.00231930436153 })
end
it "parses floats with negative exponents and a large E" do
json = '{"foo": 1.602176565E-19}'
- expect(parser.parse(json)).to eql({"foo" => 1.602176565e-19})
+ expect(parser.parse(json)).to eql({ "foo" => 1.602176565e-19 })
end
it "parses floats with negative exponents and a small e" do
json = '{"foo": 6.6260689633e-34 }'
- expect(parser.parse(json)).to eql({"foo" => 6.6260689633e-34 })
+ expect(parser.parse(json)).to eql({ "foo" => 6.6260689633e-34 })
end
it "parses floats with positive exponents and a large E" do
json = '{"foo": 6.0221413E+23}'
- expect(parser.parse(json)).to eql({"foo" => 6.0221413e+23})
+ expect(parser.parse(json)).to eql({ "foo" => 6.0221413e+23 })
end
it "parses floats with positive exponents and a small e" do
json = '{"foo": 8.9875517873681764e+9 }'
- expect(parser.parse(json)).to eql({"foo" => 8.9875517873681764e+9 })
+ expect(parser.parse(json)).to eql({ "foo" => 8.9875517873681764e+9 })
end
it "parses floats with an exponent without a sign and a large E" do
json = '{"foo": 2.99792458E8 }'
- expect(parser.parse(json)).to eql({"foo" => 2.99792458e+8 })
+ expect(parser.parse(json)).to eql({ "foo" => 2.99792458e+8 })
end
it "parses floats with an exponent without a sign and a small e" do
json = '{"foo": 1.0973731568539e7 }'
- expect(parser.parse(json)).to eql({"foo" => 1.0973731568539e+7 })
+ expect(parser.parse(json)).to eql({ "foo" => 1.0973731568539e+7 })
end
end
context "when parsing unicode in hash keys" do
it "handles heavy metal umlauts in keys" do
json = '{"München": "Bayern"}'
- expect(parser.parse(json)).to eql({"München" => "Bayern"})
+ expect(parser.parse(json)).to eql({ "München" => "Bayern" })
end
end
end