Otaqui.Com

Pete Otaqui’s blog about web development and everything else

Using a Proxy with Cucumber, Webrat and Mechanize

leave a comment

If you’re writing Cucumber tests using Webrat and Mechanize to test a site, and you are behind a proxy server, you can do something like this to tell mechanize about it in your webrat_steps.rb file:


When /^I am on (.+)$/ do |page_name|
webrat.adapter.mechanize.set_proxy('proxy.host.com',8080)
visit path_to(page_name)
end

I’m sure there’s a tidier way to do this, but it’s quick and it works with the following gem versions:

Cucumber 0.3.11
Webrat 0.5.3
Mechanize 0.9.3

Written by pete

December 17th, 2009 at 4:15 pm

Posted in Professional

Tagged with , ,

Leave a Reply