How to assert that an input element is empty in Ruby on Rails tests
I want to ensure that the password fields are empty when editing a user. How do I do this in a fun开发者_如何学Cctional test?
I've tried both of these variants:
assert_select "input[name=?][value=?]", 'user[password1]', ''
and
assert_tag :tag => "input", :attributes => {:name => "user[password1]", :value => ""}
Both fail because there is no value=
attribute present in the generated html. I don't see any way of testing that an attribute is not present in the generated html?
Try this:
assert_select 'input:not([value])[name="user[password1]"]', true
in cucumber/webrat sth like page.should_not have_xpath("//input[contains(@value, \"\")]")
works
精彩评论