summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-07-09 13:51:28 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-07-09 13:51:28 -0700
commitaa2afb68a78fed7a71a6d574586202a0377eba25 (patch)
tree38a1750ae150495501cfb39ade622be3822fabe3 /spec
parent457842ff8567742d94cb079f439c38403a15d8b8 (diff)
downloadffi-yajl-aa2afb68a78fed7a71a6d574586202a0377eba25.tar.gz
yet more copslcg/more-cops
Diffstat (limited to 'spec')
-rw-r--r--spec/ffi_yajl/encoder_spec.rb8
-rw-r--r--spec/ffi_yajl/parser_spec.rb48
-rw-r--r--spec/spec_helper.rb4
3 files changed, 30 insertions, 30 deletions
diff --git a/spec/ffi_yajl/encoder_spec.rb b/spec/ffi_yajl/encoder_spec.rb
index d8ee707..91009f4 100644
--- a/spec/ffi_yajl/encoder_spec.rb
+++ b/spec/ffi_yajl/encoder_spec.rb
@@ -29,12 +29,12 @@ describe "FFI_Yajl::Encoder" do
let(:encoder) { FFI_Yajl::Encoder.new(options) }
- it "encodes hashes in keys as strings", :ruby_gte_193 => true do
+ it "encodes hashes in keys as strings", ruby_gte_193: true do
ruby = { { 'a' => 'b' } => 2 }
expect(encoder.encode(ruby)).to eq('{"{\"a\"=>\"b\"}":2}')
end
- it "encodes arrays in keys as strings", :ruby_gte_193 => true do
+ it "encodes arrays in keys as strings", ruby_gte_193: true do
ruby = { [0, 1] => 2 }
expect(encoder.encode(ruby)).to eq('{"[0, 1]":2}')
end
@@ -102,7 +102,7 @@ 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
@@ -190,7 +190,7 @@ describe "FFI_Yajl::Encoder" do
end
context "when validate_utf8 is off" do
- let(:options) { { :validate_utf8 => false } }
+ let(:options) { { validate_utf8: false } }
it "does not raise an error" do
expect { encoder.encode(ruby) }.not_to raise_error
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb
index 968e0ee..dde8646 100644
--- a/spec/ffi_yajl/parser_spec.rb
+++ b/spec/ffi_yajl/parser_spec.rb
@@ -87,7 +87,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"key": /* this is a comment */ "value"}' }
context "when allow_comments is false" do
- let(:options) { { :allow_comments => false } }
+ let(:options) { { allow_comments: false } }
it "should not parse" do
expect { parser }.to raise_error(FFI_Yajl::ParseError)
@@ -95,7 +95,7 @@ describe "FFI_Yajl::Parser" do
end
context "when allow_comments is true" do
- let(:options) { { :allow_comments => true } }
+ let(:options) { { allow_comments: true } }
it "should parse" do
expect(parser).to eq("key" => "value")
@@ -115,7 +115,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { %{{"key": \n/*\n this is a multiline comment \n*/\n "value"}} }
context "when allow_comments is false" do
- let(:options) { { :allow_comments => false } }
+ let(:options) { { allow_comments: false } }
it "should not parse" do
expect { parser }.to raise_error(FFI_Yajl::ParseError)
@@ -123,7 +123,7 @@ describe "FFI_Yajl::Parser" do
end
context "when allow_comments is true" do
- let(:options) { { :allow_comments => true } }
+ let(:options) { { allow_comments: true } }
it "should parse" do
expect(parser).to eq("key" => "value")
@@ -135,7 +135,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { %{{"key": \n// this is an inline comment\n "value"}} }
context "when allow_comments is false" do
- let(:options) { { :allow_comments => false } }
+ let(:options) { { allow_comments: false } }
it "should not parse" do
expect { parser }.to raise_error(FFI_Yajl::ParseError)
@@ -143,7 +143,7 @@ describe "FFI_Yajl::Parser" do
end
context "when allow_comments is true" do
- let(:options) { { :allow_comments => true } }
+ let(:options) { { allow_comments: true } }
it "should parse" do
expect(parser).to eq("key" => "value")
@@ -152,14 +152,14 @@ describe "FFI_Yajl::Parser" do
end
context "when json is invalid UTF8" do
- let(:json) { "[\"#{"\201\203"}\"]" }
+ let(:json) { "[\"\201\203\"]" }
it "should not parse by default" do
expect { parser }.to raise_error(FFI_Yajl::ParseError)
end
context "when :dont_validate_strings is set to true" do
- let(:options) { { :dont_validate_strings => true } }
+ let(:options) { { dont_validate_strings: true } }
it "should parse" do
expect(parser).to eq(["\x81\x83"])
@@ -167,7 +167,7 @@ describe "FFI_Yajl::Parser" do
end
context "when :dont_validate_strings is set to false" do
- let(:options) { { :dont_validate_strings => false } }
+ let(:options) { { dont_validate_strings: false } }
it "should not parse" do
expect { parser }.to raise_error(FFI_Yajl::ParseError)
@@ -175,14 +175,14 @@ describe "FFI_Yajl::Parser" do
end
context "when :check_utf8 is set to true" do
- let(:options) { { :check_utf8 => true } }
+ let(:options) { { check_utf8: true } }
it "should not parse" do
expect { parser }.to raise_error(FFI_Yajl::ParseError)
end
context "when :dont_validate_strings is set to true" do
- let(:options) { { :check_utf8 => true, :dont_validate_strings => true } }
+ let(:options) { { check_utf8: true, dont_validate_strings: true } }
it "should raise an ArgumentError" do
expect { parser }.to raise_error(ArgumentError)
@@ -190,7 +190,7 @@ describe "FFI_Yajl::Parser" do
end
context "when :dont_validate_strings is set to false" do
- let(:options) { { :check_utf8 => true, :dont_validate_strings => false } }
+ let(:options) { { check_utf8: true, dont_validate_strings: false } }
it "should not parse" do
expect { parser }.to raise_error(FFI_Yajl::ParseError)
@@ -199,14 +199,14 @@ describe "FFI_Yajl::Parser" do
end
context "when :check_utf8 is set to false" do
- let(:options) { { :check_utf8 => false } }
+ let(:options) { { check_utf8: false } }
it "should parse" do
expect(parser).to eq(["\x81\x83"])
end
context "when :dont_validate_strings is set to true" do
- let(:options) { { :check_utf8 => false, :dont_validate_strings => true } }
+ let(:options) { { check_utf8: false, dont_validate_strings: true } }
it "should parse" do
expect(parser).to eq(["\x81\x83"])
@@ -214,7 +214,7 @@ describe "FFI_Yajl::Parser" do
end
context "when :dont_validate_strings is set to false" do
- let(:options) { { :check_utf8 => false, :dont_validate_strings => false } }
+ let(:options) { { check_utf8: false, dont_validate_strings: false } }
it "should raise an ArgumentError" do
expect { parser }.to raise_error(ArgumentError)
@@ -239,10 +239,10 @@ describe "FFI_Yajl::Parser" do
end
context "when symbolize_keys is true" do
- let(:options) { { :symbolize_keys => true } }
+ let(:options) { { symbolize_keys: true } }
it "should symbolize keys correctly" do
- expect(parser).to eq(:key => 1234)
+ expect(parser).to eq(key: 1234)
end
end
@@ -308,10 +308,10 @@ describe "FFI_Yajl::Parser" do
end
context "when symbolize_keys is true" do
- let(:options) { { :symbolize_keys => true } }
+ let(:options) { { symbolize_keys: true } }
it "should symbolize keys correctly" do
- expect(parser).to eq(:"日本語" => 1234)
+ expect(parser).to eq("日本語": 1234)
end
if RUBY_VERSION.to_f >= 1.9
@@ -382,7 +382,7 @@ describe "FFI_Yajl::Parser" do
end
context "with allow_trailing_garbage" do
- let(:options) { { :allow_trailing_garbage => true } }
+ let(:options) { { allow_trailing_garbage: true } }
it "parses" do
expect(parser).to eq("foo" => { "foo" => 1234 })
end
@@ -474,7 +474,7 @@ describe "FFI_Yajl::Parser" do
# NOTE: parsing floats with 8 million digits on windows has some kind of huge
# perf issues likely in ruby and/or the underlying windows libs
- context "when parsing big floats", :ruby_gte_193 => true, :unix_only => true do
+ context "when parsing big floats", ruby_gte_193: true, unix_only: true do
let(:json) { '[0.' + '1' * 2**23 + ']' }
it "parses" do
@@ -482,9 +482,9 @@ describe "FFI_Yajl::Parser" do
end
end
- context "when parsing long hash keys with symbolize_keys option", :ruby_gte_193 => true do
+ context "when parsing long hash keys with symbolize_keys option", ruby_gte_193: true do
let(:json) { '{"' + 'a' * 2**23 + '": 0}' }
- let(:options) { { :symbolize_keys => true } }
+ let(:options) { { symbolize_keys: true } }
it "parses" do
expect { parser }.not_to raise_error
@@ -500,7 +500,7 @@ describe "FFI_Yajl::Parser" do
context "should raise an exception for repeated keys" do
let(:json) { '{"foo":"bar","foo":"baz"}' }
- let(:options) { { :unique_key_checking => true } }
+ let(:options) { { unique_key_checking: true } }
it "should raise" do
expect { parser }.to raise_error(FFI_Yajl::ParseError)
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 17dabcd..9ec853d 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -34,8 +34,8 @@ end
require 'ffi_yajl'
RSpec.configure do |conf|
- conf.filter_run_excluding :unix_only => true unless RUBY_PLATFORM !~ /mswin|mingw|windows/
- conf.filter_run_excluding :ruby_gte_193 => true unless RUBY_VERSION.to_f >= 2.0 || RUBY_VERSION =~ /^1\.9\.3/
+ conf.filter_run_excluding unix_only: true unless RUBY_PLATFORM !~ /mswin|mingw|windows/
+ conf.filter_run_excluding ruby_gte_193: true unless RUBY_VERSION.to_f >= 2.0 || RUBY_VERSION =~ /^1\.9\.3/
conf.order = 'random'