Module: ProxyRb::Rspec::Helpers::HttpProxy

Includes:
Capybara::DSL
Defined in:
lib/proxy_rb/rspec/helpers/http_proxy.rb

Overview

For http proxy

Instance Method Summary collapse

Instance Method Details

#proxy ⇒ Object

The proxy based on subject



45
46
47
# File 'lib/proxy_rb/rspec/helpers/http_proxy.rb', line 45

def proxy
  ProxyRb::HttpProxy.new(ProxyUrlParser.new(subject))
end

#request ⇒ Object

Get access to the request made



72
73
74
# File 'lib/proxy_rb/rspec/helpers/http_proxy.rb', line 72

def request
  Request.new(page)
end

#response ⇒ Object

Get access to the response get



77
78
79
# File 'lib/proxy_rb/rspec/helpers/http_proxy.rb', line 77

def response
  Response.new(page)
end

#visit(url) ⇒ Object Also known as: download

Visit an URL

Parameters:

  • url (String)


52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/proxy_rb/rspec/helpers/http_proxy.rb', line 52

def visit(url)
  resource = Resource.new(url)

  NonIncludes.clear_environment
  NonIncludes.configure_driver
  NonIncludes.register_capybara_driver_for_proxy(proxy)

  begin
    super(resource.to_url)
  rescue *ProxyRb.config.driver.rescuable_errors
    raise ProxyRb::UrlTimeoutError, "Failed to fetch #{resource.to_url}: Timeout occured."
  end
end