# File lib/capybara/rack_test/browser.rb, line 11 def app driver.app end
# File lib/capybara/rack_test/browser.rb, line 62 def current_url last_request.url rescue Rack::Test::Error "" end
# File lib/capybara/rack_test/browser.rb, line 79 def dom @dom ||= Nokogiri::HTML(html) end
# File lib/capybara/rack_test/browser.rb, line 83 def find(selector) dom.xpath(selector).map { |node| Capybara::RackTest::Node.new(self, node) } end
# File lib/capybara/rack_test/browser.rb, line 29 def follow(method, path, attributes = {}) return if path.gsub(/^#{request_path}/, '').start_with?('#') process_and_follow_redirects(method, path, attributes, {'HTTP_REFERER' => current_url}) end
# File lib/capybara/rack_test/browser.rb, line 87 def html last_response.body rescue Rack::Test::Error "" end
# File lib/capybara/rack_test/browser.rb, line 15 def options driver.options end
# File lib/capybara/rack_test/browser.rb, line 44 def process(method, path, attributes = {}, env = {}) new_uri = URI.parse(path) method.downcase! unless method.is_a? Symbol new_uri.path = request_path if path.start_with?("?") new_uri.path = request_path.sub(%(/[^/]*$), '/') + new_uri.path unless new_uri.path.start_with?('/') new_uri.scheme ||= @current_scheme new_uri.host ||= @current_host new_uri.port ||= @current_port unless new_uri.default_port == @current_port @current_scheme = new_uri.scheme @current_host = new_uri.host @current_port = new_uri.port reset_cache! send(method, new_uri.to_s, attributes, env.merge(options[:headers] || {})) end
# File lib/capybara/rack_test/browser.rb, line 34 def process_and_follow_redirects(method, path, attributes = {}, env = {}) process(method, path, attributes, env) if driver.follow_redirects? driver.redirect_limit.times do process(:get, last_response["Location"], {}, env) if last_response.redirect? end raise Capybara::InfiniteRedirectError, "redirected more than #{driver.redirect_limit} times, check for infinite redirects." if last_response.redirect? end end
# File lib/capybara/rack_test/browser.rb, line 75 def reset_cache! @dom = nil end
# File lib/capybara/rack_test/browser.rb, line 68 def reset_host! uri = URI.parse(Capybara.app_host || Capybara.default_host) @current_scheme = uri.scheme @current_host = uri.host @current_port = uri.port end
Generated with the Darkfish Rdoc Generator 2.