diff options
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | lib/json/add/complex.rb | 1 | ||||
-rw-r--r-- | lib/json/add/rational.rb | 1 | ||||
-rw-r--r-- | tests/json_common_interface_test.rb | 27 | ||||
-rw-r--r--[-rwxr-xr-x] | tests/json_generator_test.rb | 0 | ||||
-rw-r--r-- | tests/json_parser_test.rb | 6 |
6 files changed, 10 insertions, 26 deletions
diff --git a/.travis.yml b/.travis.yml index 78b19dd..0aaa2fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ language: ruby # Specify which ruby versions you wish to run your tests on, each version will be used rvm: - - 2.0.0 - 2.1 - 2.2 - 2.3 diff --git a/lib/json/add/complex.rb b/lib/json/add/complex.rb index 4d977e7..e63e29f 100644 --- a/lib/json/add/complex.rb +++ b/lib/json/add/complex.rb @@ -2,7 +2,6 @@ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end -defined?(::Complex) or require 'complex' class Complex diff --git a/lib/json/add/rational.rb b/lib/json/add/rational.rb index 6be4034..f776226 100644 --- a/lib/json/add/rational.rb +++ b/lib/json/add/rational.rb @@ -2,7 +2,6 @@ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end -defined?(::Rational) or require 'rational' class Rational # Deserializes JSON string by converting numerator value <tt>n</tt>, diff --git a/tests/json_common_interface_test.rb b/tests/json_common_interface_test.rb index 4fdc2b1..9148b78 100644 --- a/tests/json_common_interface_test.rb +++ b/tests/json_common_interface_test.rb @@ -152,31 +152,18 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase temp_file_containing(@json) do |filespec| parsed_object = JSON.public_send(method_name, filespec, symbolize_names: true) key_classes = parsed_object.keys.map(&:class) - assert_true key_classes.include?(Symbol) && (! key_classes.include?(String)) + assert_include(key_classes, Symbol) + assert_not_include(key_classes, String) end end - # Copied and slightly modified from https://github.com/keithrbennett/trick_bag - # (https://github.com/keithrbennett/trick_bag/blob/master/lib/trick_bag/io/temp_files.rb). - # - # For the easy creation and deletion of a temp file populated with text, - # wrapped around the code block you provide. - # - # @param text the text to write to the temporary file - # @param file_prefix optional prefix for the temporary file's name - # @yield filespec of the temporary file def temp_file_containing(text, file_prefix = '') raise "This method must be called with a code block." unless block_given? - filespec = nil - begin - Tempfile.open(file_prefix) do |file| - file << text - filespec = file.path - end - yield(filespec) - ensure - File.delete(filespec) if filespec && File.exist?(filespec) - end + Tempfile.create(file_prefix) do |file| + file << text + file.close + yield file.path end + end end diff --git a/tests/json_generator_test.rb b/tests/json_generator_test.rb index 2ecdc97..2ecdc97 100755..100644 --- a/tests/json_generator_test.rb +++ b/tests/json_generator_test.rb diff --git a/tests/json_parser_test.rb b/tests/json_parser_test.rb index e29f3f1..dce693e 100644 --- a/tests/json_parser_test.rb +++ b/tests/json_parser_test.rb @@ -222,10 +222,10 @@ class JSONParserTest < Test::Unit::TestCase assert_predicate parse('{}', :freeze => true), :frozen? assert_predicate parse('[]', :freeze => true), :frozen? assert_predicate parse('"foo"', :freeze => true), :frozen? - + if string_deduplication_available? - assert_same -'foo', parse('"foo"', :freeze => true) - assert_same -'foo', parse('{"foo": 1}', :freeze => true).keys.first + assert_same(-'foo', parse('"foo"', :freeze => true)) + assert_same(-'foo', parse('{"foo": 1}', :freeze => true).keys.first) end end |