I spent some time yesterday trying this out.
I am writing it here to save your time.

Here is the functional test’s code to check for a hyperlink with text “Back to Index” which links to the index action of the controller being tested.

link = find_tag :tag => "a", :content =>"Back to Inbox"
assert_equal @controller.url_for(:action => 'index', :only_path => true), link.attributes["href"]

It could have been done in a single assert_tag … but the statement becomes too long.

Share this: