Custom User Agent with Cucumber Tests and Webrat in Mechanize Mode

Posted by & filed under Professional.

It’s pretty straightforward to set a custom user agent with mechanize if you’re using it directly, KickAssLabs has a good example. If you’re using Mechanize through Webrat though, things are a little different. The nice thing though, is that you can do this in a step definition – allowing features to be based on different… Read more »

Using a Proxy with Cucumber, Webrat and Mechanize

Posted by & filed under Professional.

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,… Read more »

Cucumber with Webrat and Mechanize on CentOS 5

Posted by & filed under Professional.

Thanks to Chris for this one. The trick is to use JRuby and its gems, and also to install libxml2-devel $ cd ~ $ wget http://jruby.kenai.com/downloads/1.4.0/jruby-bin-1.4.0.tar.gz $ tar -C /usr/local/ -xzvf jruby-bin-1.4.0.tar.gz You should now have Jruby. Add it’s bin directory to your path, presumably in your ~/.bash_profile file: $ export PATH=$PATH:/usr/local/jruby-1.4.0/bin $ jruby -v… Read more »