Skip to content

Commit 1909435

Browse files
committed
fix creating a Proc without a block
1 parent 6e7c4b5 commit 1909435

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/excon.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def new(url, params = {})
145145
# push an additional stub onto the list to check for mock requests
146146
# @param request_params [Hash<Symbol, >] request params to match against, omitted params match all
147147
# @param response_params [Hash<Symbol, >] response params to return from matched request or block to call with params
148-
def stub(request_params = {}, response_params = nil)
148+
def stub(request_params = {}, response_params = nil, &block)
149149
if method = request_params.delete(:method)
150150
request_params[:method] = method.to_s.downcase.to_sym
151151
end
@@ -175,7 +175,7 @@ def stub(request_params = {}, response_params = nil)
175175
if response_params
176176
raise(ArgumentError.new("stub requires either response_params OR a block"))
177177
else
178-
stub = [request_params, Proc.new]
178+
stub = [request_params, block]
179179
end
180180
elsif response_params
181181
stub = [request_params, response_params]

lib/excon/connection.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def request(params={}, &block)
257257

258258
if block_given?
259259
Excon.display_warning('Excon requests with a block are deprecated, pass :response_block instead.')
260-
datum[:response_block] = Proc.new
260+
datum[:response_block] = block
261261
end
262262

263263
datum[:connection] = self

0 commit comments

Comments
 (0)