aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-05-08 01:18:12 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-05-08 15:17:15 +0900
commit2a24328e1e4a81f696f6386b4c8889bf658b9bec (patch)
treeebc942965bafb84bc6b7b07f228e220741f6793e
parent69ad77f65dfb2d4f362c3d96bc6907e3d97a099a (diff)
downloadplum-2a24328e1e4a81f696f6386b4c8889bf658b9bec.tar.gz
client: remove synchronous HTTP method methods
Using them is a bad habit.
-rw-r--r--lib/plum/client.rb21
-rw-r--r--test/plum/client/test_client.rb23
2 files changed, 0 insertions, 44 deletions
diff --git a/lib/plum/client.rb b/lib/plum/client.rb
index b232a78..55325a8 100644
--- a/lib/plum/client.rb
+++ b/lib/plum/client.rb
@@ -83,14 +83,6 @@ module Plum
@session.request(headers, body, @config.merge(options), &block)
end
- # @!method get!
- # @!method head!
- # @!method delete!
- # @param path [String] the absolute path to request (translated into :path header)
- # @param options [Hash<Symbol, Object>] the request options
- # @param block [Proc] if specified, calls the block when finished
- # Shorthand method for `Client#resume(Client#request(*args))`
-
# @!method get
# @!method head
# @!method delete
@@ -99,20 +91,10 @@ module Plum
# @param block [Proc] if specified, calls the block when finished
# Shorthand method for `#request`
%w(GET HEAD DELETE).each { |method|
- define_method(:"#{method.downcase}!") do |path, options = {}, &block|
- resume _request_helper(method, path, nil, options, &block)
- end
define_method(:"#{method.downcase}") do |path, options = {}, &block|
_request_helper(method, path, nil, options, &block)
end
}
- # @!method post!
- # @!method put!
- # @param path [String] the absolute path to request (translated into :path header)
- # @param body [String] the request body
- # @param options [Hash<Symbol, Object>] the request options
- # @param block [Proc] if specified, calls the block when finished
- # Shorthand method for `Client#resume(Client#request(*args))`
# @!method post
# @!method put
@@ -122,9 +104,6 @@ module Plum
# @param block [Proc] if specified, calls the block when finished
# Shorthand method for `#request`
%w(POST PUT).each { |method|
- define_method(:"#{method.downcase}!") do |path, body, options = {}, &block|
- resume _request_helper(method, path, body, options, &block)
- end
define_method(:"#{method.downcase}") do |path, body, options = {}, &block|
_request_helper(method, path, body, options, &block)
end
diff --git a/test/plum/client/test_client.rb b/test/plum/client/test_client.rb
index 13aa82a..2a4d8b6 100644
--- a/test/plum/client/test_client.rb
+++ b/test/plum/client/test_client.rb
@@ -2,16 +2,6 @@ require "test_helper"
using Plum::BinaryString
class ClientTest < Minitest::Test
- def test_request_sync
- server_thread = start_tls_server
- client = Client.start("127.0.0.1", LISTEN_PORT, https: true, verify_mode: OpenSSL::SSL::VERIFY_NONE)
- res1 = client.put!("/", "aaa", headers: { "header" => "ccc" })
- assert_equal("PUTcccaaa", res1.body)
- client.close
- ensure
- server_thread.join if server_thread
- end
-
def test_request_async
res2 = nil
client = nil
@@ -42,19 +32,6 @@ class ClientTest < Minitest::Test
server_thread.join if server_thread
end
- def test_raise_error_sync
- client = nil
- server_thread = start_tls_server
- Client.start("127.0.0.1", LISTEN_PORT, https: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |c|
- client = c
- assert_raises(LocalConnectionError) {
- client.get!("/connection_error")
- }
- }
- ensure
- server_thread.join if server_thread
- end
-
def test_raise_error_async_seq_resume
server_thread = start_tls_server
client = Client.start("127.0.0.1", LISTEN_PORT, https: true, verify_mode: OpenSSL::SSL::VERIFY_NONE)