How to check html attributes with rspec?
The html I created is generated by ruby ββwith:
<%= link_to "change", "http://gravatar.com/emails" %>
that leads to:
<a href="http://gravatar.com/emails">change</a>
but I want to make sure the link opens in a new tab with
target="blank"
Attribute
The rspec test looks like this:
it { should have_link('change', href: 'http://gravatar.com/emails', target: '_blank') }
but the test still passes when I don't have a generated target attribute.
I use has_selector to process each attribute:
should have_selector('a', :href => 'http://gravatar.com/emails', :target => '_blank', :content => 'change' )
I think you need capybara to have this matches http://rubydoc.info/github/jnicklas/capybara/Capybara/RSpecMatchers/HaveSelector