From f6339daff6d932bf1fa895e3bb4d284978954a39 Mon Sep 17 00:00:00 2001 From: Jonas Nicklas Date: Mon, 9 Nov 2009 23:12:08 +0100 Subject: [PATCH] Make weird form submission slightly less weird --- lib/webcat/driver/rack_test_driver.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/webcat/driver/rack_test_driver.rb b/lib/webcat/driver/rack_test_driver.rb index 652d959d..427ab65f 100644 --- a/lib/webcat/driver/rack_test_driver.rb +++ b/lib/webcat/driver/rack_test_driver.rb @@ -42,23 +42,23 @@ class Webcat::Driver::RackTest class Form < Node def params(button) params = [] - params = node.xpath("//input[@type='text']").inject(params) do |agg, input| + params << node.xpath("//input[@type='text']").inject([]) do |agg, input| agg << param(input['name'].to_s, input['value'].to_s) agg end - params = node.xpath("//textarea").inject(params) do |agg, textarea| + params << node.xpath("//textarea").inject([]) do |agg, textarea| agg << param(textarea['name'].to_s, textarea.text.to_s) agg end - params = node.xpath("//input[@type='radio']").inject(params) do |agg, input| + params << node.xpath("//input[@type='radio']").inject([]) do |agg, input| agg << param(input['name'].to_s, input['value'].to_s) if input['checked'] agg end - params = node.xpath("//input[@type='checkbox']").inject(params) do |agg, input| + params << node.xpath("//input[@type='checkbox']").inject([]) do |agg, input| agg << param(input['name'].to_s, input['value'].to_s) if input['checked'] agg end - params = node.xpath("//select").inject(params) do |agg, select| + params << node.xpath("//select").inject([]) do |agg, select| option = select.xpath("option[@selected]").first option ||= select.xpath('option').first agg << param(select['name'].to_s, (option['value'] || option.text).to_s) if option