fix post method in mechanize adapter to handle data as array or hash
it fixes spec/integration/mechanize/sample_app.rb:20
This commit is contained in:
parent
c49123c772
commit
06bb72d24f
|
@ -22,13 +22,19 @@ module Webrat #:nodoc:
|
|||
|
||||
def post(url, data, headers_argument_not_used = nil)
|
||||
post_data = data.inject({}) do |memo, param|
|
||||
case param.last
|
||||
case param
|
||||
when Hash
|
||||
param.last.each {|attribute, value| memo["#{param.first}[#{attribute}]"] = value }
|
||||
else
|
||||
memo[param.first] = param.last
|
||||
param.each {|attribute, value| memo[attribute] = value }
|
||||
memo
|
||||
when Array
|
||||
case param.last
|
||||
when Hash
|
||||
param.last.each {|attribute, value| memo["#{param.first}[#{attribute}]"] = value }
|
||||
else
|
||||
memo[param.first] = param.last
|
||||
end
|
||||
memo
|
||||
end
|
||||
memo
|
||||
end
|
||||
@response = mechanize.post(url, post_data)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue