[rspec-users] [RSpec] matcher for href

James Byrne lists at ruby-forum.com
Mon Jan 19 14:11:19 EST 2009


Of the several ways available to test for this, what would be the
preferred way to see if the following is present in an html document
WITHOUT actually following the link?

  <a href="/users/new">

I tried this:

 response.body.should have_text('href="/users/new"')

But this test fails, even though the rake features report is this:

   expected "href=\"/users/new\"", got ...

    ... </tr>\n\n</table>\n\n<br />\n\n<a href=\"/users/new\">New
user</a>\n\n</div>\n\r\n\r\n ...

So, I am nonplussed by the report that it did not find what was present.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list