Added field value escaping
This commit is contained in:
parent
2fd734f9ff
commit
e30e88594f
@ -56,7 +56,6 @@ module Webrat
|
|||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
return nil if disabled?
|
return nil if disabled?
|
||||||
value = @value.to_s.gsub('&', '%26')
|
|
||||||
param_parser.parse_query_parameters("#{name}=#{value}")
|
param_parser.parse_query_parameters("#{name}=#{value}")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -78,6 +77,10 @@ module Webrat
|
|||||||
@element["name"]
|
@element["name"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def value
|
||||||
|
CGI.escape(@value.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
def labels
|
def labels
|
||||||
@labels ||= label_elements.map { |element| Label.new(self, element) }
|
@labels ||= label_elements.map { |element| Label.new(self, element) }
|
||||||
end
|
end
|
||||||
|
@ -157,4 +157,17 @@ describe "fills_in" do
|
|||||||
@session.fills_in :email, :with => "foo@example.com"
|
@session.fills_in :email, :with => "foo@example.com"
|
||||||
@session.clicks_button
|
@session.clicks_button
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user