diff --git a/spec/lib/http/client_spec.rb b/spec/lib/http/client_spec.rb index 3ce51175..eb4eb1e2 100644 --- a/spec/lib/http/client_spec.rb +++ b/spec/lib/http/client_spec.rb @@ -10,7 +10,8 @@ StubbedClient = Class.new(HTTP::Client) do def perform(request, options) - stubs.fetch(request.uri) { super(request, options) } + stubbed = stubs[request.uri] + stubbed ? stubbed.call(request) : super(request, options) end def stubs @@ -27,22 +28,26 @@ def stub(stubs) end def redirect_response(location, status = 302) - HTTP::Response.new( - :status => status, - :version => "1.1", - :headers => {"Location" => location}, - :body => "", - :request => HTTP::Request.new(:verb => :get, :uri => "http://example.com") - ) + lambda do |request| + HTTP::Response.new( + :status => status, + :version => "1.1", + :headers => {"Location" => location}, + :body => "", + :request => request + ) + end end def simple_response(body, status = 200) - HTTP::Response.new( - :status => status, - :version => "1.1", - :body => body, - :request => HTTP::Request.new(:verb => :get, :uri => "http://example.com") - ) + lambda do |request| + HTTP::Response.new( + :status => status, + :version => "1.1", + :body => body, + :request => request + ) + end end describe "following redirects" do