Make fills_in work with passwords

This commit is contained in:
Bryan Helmkamp 2008-04-07 19:19:30 -04:00
parent 6165e132b6
commit aff769c4e7
2 changed files with 127 additions and 115 deletions

View File

@ -29,7 +29,7 @@ module Webrat
# <tt>field</tt> can be either the value of a name attribute (i.e. <tt>user[email]</tt>)
# or the text inside a <tt><label></tt> element that points at the <tt><input></tt> field.
def fills_in(id_or_name_or_label, options = {})
field = find_field(id_or_name_or_label, TextField, TextareaField)
field = find_field(id_or_name_or_label, TextField, TextareaField, PasswordField)
field.set(options[:with])
end

View File

@ -21,6 +21,18 @@ class FillsInTest < Test::Unit::TestCase
@session.clicks_button
end
def test_should_work_with_password_fields
@response.stubs(:body).returns(<<-EOS)
<form method="post" action="/login">
<input id="user_text" name="user[text]" type="password" />
<input type="submit" />
</form>
EOS
@session.expects(:post_via_redirect).with("/login", "user" => {"text" => "pass"})
@session.fills_in "user_text", :with => "pass"
@session.clicks_button
end
def test_should_fail_if_input_not_found
@response.stubs(:body).returns(<<-EOS)
<form method="get" action="/login">