summaryrefslogtreecommitdiff
path: root/tests/json_common_interface_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tests/json_common_interface_test.rb')
-rw-r--r--tests/json_common_interface_test.rb27
1 files changed, 7 insertions, 20 deletions
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