public
Created

monkey patch to fix webrat follow redirect behaviour with rails 3

  • Download Gist
env.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12
# features/support/env.rb
 
require 'webrat'
require 'webrat/core/matchers'
 
Webrat.configure do |config|
config.mode = :rack
config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end
 
World(Webrat::Methods)
World(Webrat::Matchers)
webrat.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12
# features/support/webrat.rb
module Webrat
class Session
def current_host
URI.parse(current_url).host || @custom_headers["Host"] || default_current_host
end
def default_current_host
adapter.class==Webrat::RackAdapter ? "example.org" : "www.example.com"
end
end
end

Thanks, this just solved my problem

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.