Added field value escaping

This commit is contained in:
Miha Filej 2008-10-21 18:13:42 +02:00
parent 2fd734f9ff
commit e30e88594f
2 changed files with 18 additions and 2 deletions

View File

@ -56,10 +56,9 @@ module Webrat
def to_param
return nil if disabled?
value = @value.to_s.gsub('&', '%26')
param_parser.parse_query_parameters("#{name}=#{value}")
end
def set(value)
@value = value
end
@ -78,6 +77,10 @@ module Webrat
@element["name"]
end
def value
CGI.escape(@value.to_s)
end
def labels
@labels ||= label_elements.map { |element| Label.new(self, element) }
end

View File

@ -157,4 +157,17 @@ describe "fills_in" do
@session.fills_in :email, :with => "foo@example.com"
@session.clicks_button
end
it "should escape field values" do
@session.response_body = <<-EOS
<form method="post" action="/users">
<label for="user_phone">Phone</label>
<input id="user_phone" name="user[phone]" type="text" />
<input type="submit" />
</form>
EOS
@session.should_receive(:post).with("/users", "user" => {"phone" => "+1 22 33"})
@session.fills_in 'Phone', :with => "+1 22 33"
@session.clicks_button
end
end