Sunday, February 15, 2015

Testing Multiple Attributes of an Input Field

Sometimes in a view or feature spec, you want to test multiple attributes of an input field (or some other field). For example, you might want to test that the input field is a checkbox and is checked, as well as testing that the field has the id #rawr. This is how you would do that in a view spec (feature spec is similar):

 expect(content).to have_css("input[type='checkbox'][checked='checked']#rawr")