test/test_http.rb in zold-0.31.5 vs test/test_http.rb in zold-0.31.6
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-# Copyright (c) 2018-2023 Zerocracy, Inc.
+# Copyright (c) 2018-2023 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -135,17 +135,17 @@
socket.close
end
end
latch.wait
res = Tempfile.open do |f|
- IO.write(f, 'How are you?')
+ File.write(f, 'How are you?')
Zold::Http.new(uri: "http://127.0.0.1:#{port}/").put(f)
end
assert_equal(200, res.status, res)
assert(body.include?('Content-Length: 12'), body)
assert(body.include?('Content-Type: text/plain'))
- headers = body.split("\n").select { |t| t =~ /^[a-zA-Z-]+:.+$/ }
+ headers = body.split("\n").grep(/^[a-zA-Z-]+:.+$/)
assert_equal(headers.count, headers.uniq.count)
thread.kill
thread.join
end
end
@@ -186,11 +186,11 @@
end
end
latch.wait
content = "how are you\nmy friend"
res = Tempfile.open do |f|
- IO.write(f, content)
+ File.write(f, content)
Zold::Http.new(uri: "http://localhost:#{port}/").put(f)
end
assert_equal(200, res.status, res)
assert(res.body.include?(content), res)
thread.kill
@@ -213,10 +213,10 @@
end
end
latch.wait
body = Tempfile.open do |f|
Zold::Http.new(uri: "http://localhost:#{port}/").get_file(f)
- IO.read(f)
+ File.read(f)
end
assert(body.include?(content), body)
thread.kill
thread.join
end