har*_*ald 3 html forms testing ruby-on-rails
我想确保在编辑用户时密码字段为空。我如何在功能测试中做到这一点?
我已经尝试了这两种变体:
assert_select "input[name=?][value=?]", 'user[password1]', ''
Run Code Online (Sandbox Code Playgroud)
和
assert_tag :tag => "input", :attributes => {:name => "user[password1]", :value => ""}
Run Code Online (Sandbox Code Playgroud)
两者都失败,因为value=
生成的 html 中不存在属性。我没有看到任何测试生成的 html 中不存在属性的方法?
尝试这个:
assert_select 'input:not([value])[name="user[password1]"]', true
Run Code Online (Sandbox Code Playgroud)