I have this html.erb Rails form:
<h1 class=new_vendor_header>New Vendor Form</h1> <%= form_for(@vendor) do |f| %> <%= f.label :name %> <%= f.text_field :name, placeholder: "ex: Jeff" %> <%= f.submit "Submit" %> <% end %>
It goes through:
expect(page).to have_selector('input[placeholder="ex: Jeff"]')
But this is not so:
expect(page).to have_field('input[placeholder="ex: Jeff"]')
and this is not so:
expect(page).to have_selector('input[placeholder="ex: Jeff"]')
The selector refers to the HTML selector on the right, so does it refer to html elements? have_css I thought they were looking for CSS, but it seems to be doing more. Here is an example from the cover:
response.body.should have_css("input", :count => 3)
And this is similar to HTML input selectors.
So what is the difference and why the other two do not work in my example?
source share