[rspec-users] Just trying out cucumber

David Chelimsky dchelimsky at gmail.com
Tue Nov 25 09:44:04 EST 2008


On Tue, Nov 25, 2008 at 2:52 AM, Matt Wynne <matt at mattwynne.net> wrote:
>
> On 25 Nov 2008, at 02:23, Andrew Premdas wrote:
>
>> You definitely should have an id for your output. One of the really
>> good things about feature testing is that it helps you identify what
>> needs to be seen in your output, and by that I don't mean specific
>> text, but rather a semantic meaning of your output, in this case a
>> project containing a token. You should be using css id's and/or
>> classes to identify these things.
>>
>> This will help you write less brittle features that don't depend on
>> the content of something, or even worse the label describing it.
>
> +1
>
> The person I often sit down to pair with on features is our CSS / markup
> hacker. You can write really nice features if you work to make them
> meaningful within the context of the markup (and make the markup meaningful
> within the context of the feature).
>
> As well as #assert_select, check out the #within method that webrat gives
> you - you can use it to scope queries against the DOM of the response down
> to part of the page.
>
> Also I'd suggest looking at using Hpricot for validating the response - it's
> used internally by webrat and is a really nice API for walking the HTML
> produced by the response.

Actually Webrat now uses nokogiri and ships with two very powerful
matchers: have_xpath and have_selector that might eliminate your need
to open up hpricot or nokogiri directly in the steps.

http://github.com/brynary/webrat/tree/master

Cheers,
David

>
> cheers,
> Matt
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list