0
@@ -139,6 +139,18 @@ module ActionController
0
add_form_data(input, input.attributes["value"])
0
+ # Verifies that an input radio button exists on the current page and marks it
0
+ # as checked, so that the value will be submitted with the form.
0
+ # chooses 'First Option'
0
+ radio = find_field_by_name_or_label(field)
0
+ return flunk("Could not find radio button #{field.inspect}") if radio.nil?
0
+ return flunk("Input #{radio.inspect} is not a radio button") unless radio.attributes['type'] == 'radio'
0
+ add_form_data(radio, radio.attributes["value"] || "on")
0
# Verifies that a submit button exists for the form, then submits the form, follows
0
# any redirects, and verifies the final page was successful.
0
@@ -158,6 +170,21 @@ module ActionController
0
def submits_form(form_id = nil) # :nodoc:
0
+ # Saves the currently loaded page out to RAILS_ROOT/tmp/ and opens it in the default
0
+ # web browser if on OS X. Useful for debugging.
0
+ def save_and_open_page
0
+ return unless File.exist?(RAILS_ROOT + "/tmp")
0
+ filename = "webrat-#{Time.now.to_i}.html"
0
+ File.open(RAILS_ROOT + "/tmp/#{filename}", "w") do |f|
0
+ `open tmp/#{filename}`
0
protected # Methods you could call, but probably shouldn't
0
@@ -222,7 +249,7 @@ module ActionController
0
def find_button(value = nil) # :nodoc:
0
return nil unless value
0
- submit_buttons.detect { |el| el.attributes["value"] =
= value }
0
+ submit_buttons.detect { |el| el.attributes["value"] =
~ /^\W*#{value}\b/i }
0
def add_form_data(input_element, value) # :nodoc:
0
@@ -269,7 +296,12 @@ module ActionController
0
debug_log "REQUESTING PAGE: #{method.to_s.upcase} #{url} with #{data.inspect}"
0
self.send "#{method}_via_redirect", @current_url, data || {}
0
- assert_response :success
0
+ if response.body =~ /Exception caught/ || response.body.blank?
0
+ assert_response :success
0
@@ -343,7 +375,8 @@ module ActionController
0
def add_default_params_for(form) # :nodoc:
0
add_default_params_from_inputs_for(form)
0
add_default_params_from_checkboxes_for(form)
0
- add_default_params_from_textateas_for(form)
0
+ add_default_params_from_radio_buttons_for(form)
0
+ add_default_params_from_textareas_for(form)
0
def add_default_params_from_inputs_for(form) # :nodoc:
0
@@ -362,7 +395,16 @@ module ActionController
0
- def add_default_params_from_textateas_for(form) # :nodoc:
0
+ def add_default_params_from_radio_buttons_for(form) # :nodoc:
0
+ (form / "input").each do |input|
0
+ next if input.attributes["type"] != "radio"
0
+ if input.attributes["checked"] == "checked"
0
+ add_form_data(input, input.attributes["value"])
0
+ def add_default_params_from_textareas_for(form) # :nodoc:
0
(form / "textarea").each do |input|
0
add_form_data(input, input.inner_html)
Comments
No one has commented yet.