开发者

How to assert that an input element is empty in Ruby on Rails tests

开发者 https://www.devze.com 2023-03-12 05:29 出处:网络
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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消