Refactoring request_page usage

This commit is contained in:
Bryan Helmkamp 2008-07-27 12:46:36 -04:00
parent c64556f489
commit cc56a855cd
4 changed files with 6 additions and 7 deletions

View File

@ -53,7 +53,7 @@ module Webrat
end end
def submit def submit
Page.new(@page.session, form_action, form_method, params) @page.session.request_page(form_action, form_method, params)
end end
protected protected

View File

@ -13,9 +13,9 @@ module Webrat
options[:javascript] = true if options[:javascript].nil? options[:javascript] = true if options[:javascript].nil?
if options[:javascript] if options[:javascript]
Page.new(@page.session, absolute_href, method, data) @page.session.request_page(absolute_href, method, data)
else else
Page.new(@page.session, absolute_href, :get, {}) @page.session.request_page(absolute_href, :get, {})
end end
end end

View File

@ -68,10 +68,6 @@ module Webrat
def load_page def load_page
session.request_page(@url, @method, @data) session.request_page(@url, @method, @data)
save_and_open_page if session.exception_caught?
flunk("Page load was not successful (Code: #{session.response_code.inspect})") unless session.success_code?
reset_scope reset_scope
end end

View File

@ -29,6 +29,9 @@ module Webrat
def request_page(url, method, data) def request_page(url, method, data)
debug_log "REQUESTING PAGE: #{method.to_s.upcase} #{url} with #{data.inspect}" debug_log "REQUESTING PAGE: #{method.to_s.upcase} #{url} with #{data.inspect}"
send "#{method}", url, data || {} send "#{method}", url, data || {}
save_and_open_page if exception_caught?
flunk("Page load was not successful (Code: #{session.response_code.inspect})") unless success_code?
end end
def success_code? def success_code?