Make fills_in work with passwords
This commit is contained in:
parent
6165e132b6
commit
aff769c4e7
@ -29,7 +29,7 @@ module Webrat
|
|||||||
# <tt>field</tt> can be either the value of a name attribute (i.e. <tt>user[email]</tt>)
|
# <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.
|
# 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 = {})
|
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])
|
field.set(options[:with])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,6 +21,18 @@ class FillsInTest < Test::Unit::TestCase
|
|||||||
@session.clicks_button
|
@session.clicks_button
|
||||||
end
|
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
|
def test_should_fail_if_input_not_found
|
||||||
@response.stubs(:body).returns(<<-EOS)
|
@response.stubs(:body).returns(<<-EOS)
|
||||||
<form method="get" action="/login">
|
<form method="get" action="/login">
|
||||||
|
Loading…
Reference in New Issue
Block a user