diff --git a/.travis.yml b/.travis.yml index 78b19dd8..0aaa2fbb 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 4d977e75..e63e29fd 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 6be40345..f7762260 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 n, diff --git a/tests/json_common_interface_test.rb b/tests/json_common_interface_test.rb index 4fdc2b11..9148b78c 100644 --- a/tests/json_common_interface_test.rb +++ b/tests/json_common_interface_test.rb @@ -152,31 +152,18 @@ def test_load_file_with_option_shared(method_name) 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 old mode 100755 new mode 100644 diff --git a/tests/json_parser_test.rb b/tests/json_parser_test.rb index e29f3f12..dce693e5 100644 --- a/tests/json_parser_test.rb +++ b/tests/json_parser_test.rb @@ -222,10 +222,10 @@ def test_freeze 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