public
Description: Webrat - Ruby Acceptance Testing for Web applications
Home | Edit | New

Mechanize

Using mechanize is easy, just make World be a MechanizeAdapter (renamed from MechanizeSession in e4ea9134a72191c70d37205d8d4533cbc894154e ) with the matchers you want mixed in.

Don’t forget to change your visit argument to point to a fully qualified server you want to hit, and make sure that the server is actually running (e.g. something on localhost on a certain port).

require 'webrat'

Webrat.configure do |config|
  config.mode = :mechanize
end

class MechanizeWorld < Webrat::MechanizeAdapter
  include Webrat::Matchers
  include Webrat::Methods
  # no idea why we need this but without it response_code is not always recognized
  Webrat::Methods.delegate_to_session :response_code, :response_body
end

World do
  MechanizeWorld.new
end
Last edited by wolfmanjm, Mon Nov 09 14:06:42 -0800 2009
Home | Edit | New
Versions: