是否可以使用带有capybara的HTTP代理?

Kev*_* Qi 3 capybara

Capybara的API似乎不支持配置HTTP代理.有没有办法使用它?

上下文:我正在使用带黄瓜的capybara来测试rails应用程序,并使用akephalos作为javascript驱动程序.script页面上有一个标记向外部网站发出请求(在本例中为maps.google.com).黄瓜测试失败,并显示以下消息:

org.apache.http.conn.HttpHostConnectException: Connection to http://maps.google.com refused (NativeException)
(drbunix:///tmp/akephalos.24700.sock) -e:1
./features/step_definitions/named_element_steps.rb:20
Run Code Online (Sandbox Code Playgroud)

art*_*ave 5

我不知道Akephalos,但是Selenium/Firefox当然可以:

  Capybara.register_driver :selenium do |app|
    profile = Selenium::WebDriver::Firefox::Profile.new

    profile["network.proxy.type"] = 1 # manual proxy config
    profile["network.proxy.http"] = "http://example.com"
    profile["network.proxy.http_port"] = 80

    Capybara::Selenium::Driver.new(app, :profile => profile)
  end
Run Code Online (Sandbox Code Playgroud)