Expose current DOM (as an Hpricot object) as current_dom. Fix SSL support

This commit is contained in:
Bryan Helmkamp 2008-08-10 16:32:03 -04:00
parent f0ffd19be1
commit 549f462f65
4 changed files with 21 additions and 12 deletions

View File

@ -10,6 +10,7 @@
* Minor enhancements * Minor enhancements
* Expose current DOM (as an Hpricot object) as current_dom
* Add support for disabling JavaScript when clicking a link to enable testing of both JS * Add support for disabling JavaScript when clicking a link to enable testing of both JS
and non-JS implementations (Luke Melia and Bryan Helmkamp) and non-JS implementations (Luke Melia and Bryan Helmkamp)
* Support &nbsp's as spaces in matching link text (Patch from Luke Melia) * Support &nbsp's as spaces in matching link text (Patch from Luke Melia)

View File

@ -162,6 +162,18 @@ module Webrat
alias_method :click_button, :clicks_button alias_method :click_button, :clicks_button
def dom # :nodoc:
return @dom if defined?(@dom) && @dom
@dom = Hpricot(@html)
if @selector
html = (@dom / @selector).first.to_html
@dom = Hpricot(html)
end
return @dom
end
protected protected
def find_select_option(option_text, id_or_name_or_label) def find_select_option(option_text, id_or_name_or_label)
@ -224,17 +236,5 @@ module Webrat
end end
end end
def dom # :nodoc:
return @dom if defined?(@dom) && @dom
@dom = Hpricot(@html)
if @selector
html = (@dom / @selector).first.to_html
@dom = Hpricot(html)
end
return @dom
end
end end
end end

View File

@ -30,6 +30,10 @@ module Webrat
open_in_browser(filename) open_in_browser(filename)
end end
def current_dom
current_scope.dom
end
# For backwards compatibility -- removing in 1.0 # For backwards compatibility -- removing in 1.0
def current_page def current_page
page = OpenStruct.new page = OpenStruct.new

View File

@ -15,18 +15,22 @@ module Webrat
end end
def get(url, data) def get(url, data)
update_protocol(url)
@integration_session.get_via_redirect(url, data) @integration_session.get_via_redirect(url, data)
end end
def post(url, data) def post(url, data)
update_protocol(url)
@integration_session.post_via_redirect(url, data) @integration_session.post_via_redirect(url, data)
end end
def put(url, data) def put(url, data)
update_protocol(url)
@integration_session.put_via_redirect(url, data) @integration_session.put_via_redirect(url, data)
end end
def delete(url, data) def delete(url, data)
update_protocol(url)
@integration_session.delete_via_redirect(url, data) @integration_session.delete_via_redirect(url, data)
end end