how to test html attributes with rspec?
问题 the html I have is generated by ruby with: <%= link_to "change", "http://gravatar.com/emails" %> which results in: <a href="http://gravatar.com/emails">change</a> but I want to ensure that the link opens in a new tab with the target="blank" attribute the rspec test looks like: it { should have_link('change', href: 'http://gravatar.com/emails', target: '_blank') } but the test still passes when I don't have the target attribute being generated. 回答1: The following works for me with capybara 1.1