summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-06-20 15:37:38 -0700
committerTim Smith <tsmith@chef.io>2017-06-20 15:37:38 -0700
commit672fce3aed2d68e7362dc5cfeb72df78f30eb3a2 (patch)
tree76598d0c31493ca6fa8a8353402136cf8003b997 /spec
parentf3f92275f804f4c6cf93ee054af7d4ba3e50030a (diff)
downloadffi-yajl-672fce3aed2d68e7362dc5cfeb72df78f30eb3a2.tar.gz
Switch from reek/rubocop to chefstyle
Reek doesn't work with modern Rake Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/ffi_yajl/encoder_spec.rb20
-rw-r--r--spec/ffi_yajl/map_library_name_spec.rb4
-rw-r--r--spec/ffi_yajl/parser_spec.rb14
-rw-r--r--spec/spec_helper.rb8
4 files changed, 23 insertions, 23 deletions
diff --git a/spec/ffi_yajl/encoder_spec.rb b/spec/ffi_yajl/encoder_spec.rb
index 724277b..7a76c0a 100644
--- a/spec/ffi_yajl/encoder_spec.rb
+++ b/spec/ffi_yajl/encoder_spec.rb
@@ -21,8 +21,8 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-require 'spec_helper'
-require 'date'
+require "spec_helper"
+require "date"
describe "FFI_Yajl::Encoder" do
let(:options) { {} }
@@ -30,7 +30,7 @@ describe "FFI_Yajl::Encoder" do
let(:encoder) { FFI_Yajl::Encoder.new(options) }
it "encodes hashes in keys as strings", ruby_gte_193: true do
- ruby = { { 'a' => 'b' } => 2 }
+ ruby = { { "a" => "b" } => 2 }
expect(encoder.encode(ruby)).to eq('{"{\"a\"=>\"b\"}":2}')
end
@@ -126,23 +126,23 @@ describe "FFI_Yajl::Encoder" do
end
it "can encode Date objects" do
- ruby = Date.parse('2001-02-03')
+ ruby = Date.parse("2001-02-03")
expect(encoder.encode(ruby)).to eq( '"2001-02-03"' )
end
it "can encode StringIOs" do
- ruby = { "foo" => StringIO.new('THING') }
+ ruby = { "foo" => StringIO.new("THING") }
expect(encoder.encode(ruby)).to eq("{\"foo\":\"THING\"}")
end
context "when encoding Time objects in UTC timezone" do
before do
- @saved_tz = ENV['TZ']
- ENV['TZ'] = 'UTC'
+ @saved_tz = ENV["TZ"]
+ ENV["TZ"] = "UTC"
end
after do
- ENV['TZ'] = @saved_tz
+ ENV["TZ"] = @saved_tz
end
it "encodes them correctly" do
@@ -152,7 +152,7 @@ describe "FFI_Yajl::Encoder" do
end
it "can encode DateTime objects" do
- ruby = DateTime.parse('2001-02-03T04:05:06.1+07:00')
+ ruby = DateTime.parse("2001-02-03T04:05:06.1+07:00")
expect(encoder.encode(ruby)).to eq( '"2001-02-03T04:05:06+07:00"' )
end
@@ -191,7 +191,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/map_library_name_spec.rb b/spec/ffi_yajl/map_library_name_spec.rb
index 0b5e9cb..b16483f 100644
--- a/spec/ffi_yajl/map_library_name_spec.rb
+++ b/spec/ffi_yajl/map_library_name_spec.rb
@@ -20,7 +20,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-require 'spec_helper'
+require "spec_helper"
class Test
extend FFI_Yajl::MapLibraryName
@@ -107,7 +107,7 @@ describe "FFI_Yajl::MapLibraryName" do
allow(File).to receive(:file?).with(path).and_return(true)
allow(Test).to receive(:ffi_lib).with(path).and_raise(LoadError)
end
- allow(Test).to receive(:ffi_lib).with('yajl').and_return(nil)
+ allow(Test).to receive(:ffi_lib).with("yajl").and_return(nil)
Test.send(:ffi_open_yajl_library)
end
end
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb
index 750567f..be392c8 100644
--- a/spec/ffi_yajl/parser_spec.rb
+++ b/spec/ffi_yajl/parser_spec.rb
@@ -21,12 +21,12 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-require 'spec_helper'
+require "spec_helper"
describe "FFI_Yajl::Parser" do
shared_examples_for "correct json parsing" do
context "when json has 23456789012E666" do
- let(:json) { '{"key": 23456789012E666}' }
+ let(:json) { '{"key": 23456789012E666}' }
it "should return infinity" do
infinity = (1.0 / 0)
@@ -271,10 +271,10 @@ describe "FFI_Yajl::Parser" do
Encoding.default_internal = @saved_encoding
end
it "encodes keys to UTF-8" do
- expect(parser.keys.first.encoding).to eql(Encoding.find('utf-8'))
+ expect(parser.keys.first.encoding).to eql(Encoding.find("utf-8"))
end
it "encodes values to UTF-8" do
- expect(parser.values.first.encoding).to eql(Encoding.find('utf-8'))
+ expect(parser.values.first.encoding).to eql(Encoding.find("utf-8"))
end
end
@@ -349,7 +349,7 @@ describe "FFI_Yajl::Parser" do
# NOTE: we are choosing to be compatible with yajl-ruby here vs. JSON
# gem and libyajl C behavior (which is to throw an exception in this case)
context "when the JSON is empty string" do
- let(:json) { '' }
+ let(:json) { "" }
it "returns nil" do
expect(parser).to be_nil
@@ -475,7 +475,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
- let(:json) { '[0.' + '1' * 2**23 + ']' }
+ let(:json) { "[0." + "1" * 2**23 + "]" }
it "parses" do
expect { parser }.not_to raise_error
@@ -483,7 +483,7 @@ describe "FFI_Yajl::Parser" do
end
context "when parsing long hash keys with symbolize_keys option", ruby_gte_193: true do
- let(:json) { '{"' + 'a' * 2**23 + '": 0}' }
+ let(:json) { '{"' + "a" * 2**23 + '": 0}' }
let(:options) { { symbolize_keys: true } }
it "parses" do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9ec853d..48e2de5 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -26,18 +26,18 @@ $LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "../lib"))
# linked in the same process). this should work, see:
# http://stackoverflow.com/questions/3232822/linking-with-multiple-versions-of-a-library
begin
- require 'yajl'
+ require "yajl"
rescue LoadError
- puts 'WARN: yajl cannot be loaded, expected if this is jruby'
+ puts "WARN: yajl cannot be loaded, expected if this is jruby"
end
-require 'ffi_yajl'
+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.order = 'random'
+ conf.order = "random"
conf.expect_with :rspec do |rspec|
rspec.syntax = :expect