我想确保在编辑用户时密码字段为空。我如何在功能测试中做到这一点?
我尝试过这两种变体:
assert_select "input[name=?][value=?]", 'user[password1]', ''
和
assert_tag :tag => "input", :attributes => {:name => "user[password1]", :value => ""}
两者都失败,因为生成的html中没有value=
属性。我没有看到任何测试生成的html中不属性的方法吗?
答案 0 :(得分:4)
试试这个:
assert_select 'input:not([value])[name="user[password1]"]', true
答案 1 :(得分:1)
像page.should_not have_xpath("//input[contains(@value, \"\")]")
一样工作