[rspec-users] webrat within selector

Bryan Helmkamp lists at brynary.com
Tue Oct 14 02:13:56 EDT 2008


Jonathan,

This should work:

within "#user_43" do |scope|
  scope.click_link "Edit"
end

If you're using Rails' record identification HTML helpers, you can do
something like within('#' + dom_id(user)) to save some typing.

Scott's right that I'd recommend avoiding targeting IDs when possible,
but Webrat supports it in a few ways for cases where it's needed.

-Bryan

On Mon, Oct 13, 2008 at 3:36 PM, Scott Taylor
<mailing_lists at railsnewbie.com> wrote:
>
> On Oct 13, 2008, at 1:54 PM, Jonathan Linowes wrote:
>
>> anyone know if/how webrat can scope a clicks_link within a selector? eg,
>> if I have more than one "Foo" link on a page, I want to make sure I click
>> the one within a specific div
>
> I'm pretty sure clicks link can also take an id.  It's not the prettiest
> solution (in fact, I'm sure Bryan would say webrat was developed to
> *explicitly* so that you wouldn't use an id...but I digress).
>
> Scott
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
Bryan Helmkamp
http://brynary.com -- My blog


More information about the rspec-users mailing list