Edward Ocampo-Gooding
2007-Jul-22 07:00 UTC
[rspec-users] have_tag for href with specific link?
Hi folks, I''m trying out this idea of "outside-in" and writing specs for my views first. Being a person who generally starts with some scribbles of a user interface and moves right to models, this has yet to be fun, but I''m giving it a shot. My question: I''m trying to specify that an index page should show a list of things, each with a link to a delete action. How would my have_tag (or whatever I should be using) look like? Thanks, Edward
On Sun, 2007-07-22 at 03:00 -0400, Edward Ocampo-Gooding wrote:> My question: I''m trying to specify that an index page should show a list > of things, each with a link to a delete action. How would my have_tag > (or whatever I should be using) look like?have_tag just wraps assert_select from Rails, so you can use all its goodness to select specific DOM elements. In your case something like this should work: response.should have_tag(''a[href^=/stuff/delete]'') The ^= matches the beginning of the argument. Check the assert_select docs for all the possible ways to match DOM elements. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070722/58e17cd8/attachment.bin
Edward Ocampo-Gooding
2007-Jul-22 15:10 UTC
[rspec-users] have_tag for href with specific link?
Hans de Graaff wrote:> On Sun, 2007-07-22 at 03:00 -0400, Edward Ocampo-Gooding wrote: > >> My question: I''m trying to specify that an index page should show a list >> of things, each with a link to a delete action. How would my have_tag >> (or whatever I should be using) look like? > > have_tag just wraps assert_select from Rails, so you can use all its > goodness to select specific DOM elements. In your case something like > this should work: > > response.should have_tag(''a[href^=/stuff/delete]'') > > The ^= matches the beginning of the argument. Check the assert_select > docs for all the possible ways to match DOM elements.Right on. Thanks Hans.