Skip to content

Instantly share code, notes, and snippets.

@JonRowe
Created July 5, 2010 12:52
Show Gist options
  • Save JonRowe/464323 to your computer and use it in GitHub Desktop.
Save JonRowe/464323 to your computer and use it in GitHub Desktop.
#Based upon capybara 0.3.5, the important part is the path_check method
class Capybara::Driver::RackTest
def visit(path, attributes = {})
path = path_check path
return if path.gsub(/^#{current_path}/, '') =~ /^#/
get(path, attributes, env)
follow_redirects!
cache_body
end
def submit(method, path, attributes)
path = current_path if not path or path.empty?
path = path_check path
send(method, path, attributes, env)
follow_redirects!
cache_body
end
#Important part!
def path_check(path)
unless path =~ /^http/
env = request.env
path = "#{env["rack.url_scheme"]}://#{env["SERVER_NAME"]}#{path}"
end
path
rescue Rack::Test::Error
path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment