[rspec-users] Debugging trick.

Rick DeNatale rick.denatale at gmail.com
Fri Apr 18 17:14:16 EDT 2008

Some have probably already discovered this but I've been working
through some ui stories, using the rails integration test stuff.

I had a story where one very used step was failing in one place.  The
failing expectation looked like this:

       response.should have_tag("tr.group_info_row td",group_title)

I wanted to look at the response, but only for the case which was
failing, so I changed this to:

      debugger unless have_tag("tr.group_info_row
      response.should have_tag("tr.group_info_row td",group_title)

And rdebug broke right before the expectation would have thrown its
exception, and I could see the problem, which was an earlier step
which had checked that the request had redirected without following
the redirect.

I think that this pattern of using a matcher as a predicate might be
useful in future debugging sessions.

Rick DeNatale

My blog on Ruby

More information about the rspec-users mailing list