lib/em-http/mock.rb in em-http-request-0.2.5 vs lib/em-http/mock.rb in em-http-request-0.2.6

- old
+ new

@@ -1,13 +1,14 @@ module EventMachine - class HttpRequest + class MockHttpRequest < EventMachine::HttpRequest include HttpEncoding class FakeHttpClient < EventMachine::HttpClient - def setup(response) + def setup(response, uri) + @uri = uri receive_data(response) succeed(self) end def unbind @@ -54,15 +55,15 @@ end alias_method :real_send_request, :send_request protected - def send_request + def send_request(&blk) query = "#{@uri.scheme}://#{@uri.host}:#{@uri.port}#{encode_query(@uri.path, @options[:query], @uri.query)}" if s = @@registry[query] and fake = s[@method] @@registry_count[query][@method] += 1 client = FakeHttpClient.new(nil) - client.setup(fake) + client.setup(fake, @uri) client elsif @@pass_through_requests real_send_request else raise "this request #{query} for method #{@method} isn't registered, and pass_through_requests is current set to false"