Support '&' in submitted values

This commit is contained in:
Kyle Hargraves 2008-05-16 19:22:41 -05:00
parent e6aff6d37c
commit 3b72459298
2 changed files with 14 additions and 1 deletions

View File

@ -43,7 +43,8 @@ module Webrat
end
def to_param
param_parser.parse_query_parameters("#{name}=#{@value}")
value = @value.to_s.gsub('&', '%26')
param_parser.parse_query_parameters("#{name}=#{value}")
end
def set(value)

View File

@ -48,6 +48,18 @@ describe "selects" do
@session.clicks_button
end
it "should send values with HTML encoded ampersands" do
@session.response_body = <<-EOS
<form method="post" action="/login">
<select name="encoded"><option value="A &amp; B">Encoded</option></select>
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "encoded" => "A & B")
@session.selects "Encoded", :from => "encoded"
@session.clicks_button
end
it "should work with empty select lists" do
@session.response_body = <<-EOS
<form method="post" action="/login">