Created
July 5, 2010 12:52
-
-
Save JonRowe/464323 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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