Thanks for the reply, at least I can stop looking for a way to do that now.

I had been doing what you suggested, but when checking for a series of 
elements under a selector it would be nice to do this:

  rendered.should have_selector("form[action='#{new_account_path}']") do 
|form|
     form.should have_field("user_login", :type => text)
     form.should have_field("user_password", :type => text)
     form.should have_field("user_password_confirmation", :type => text)
    # ... etc ...
  end

rather than this:

  rendered.should have_selector("form[action='#{new_account_path}'] 
input#user_login[type='text']")
  rendered.should have_selector("form[action='#{new_account_path}'] 
input#user_password[type='password']")
  rendered.should have_selector("form[action='#{new_account_path}'] 
input_user_password_confirmation[type='password']")

Doesn't feel right, you know?

On Friday, December 14, 2012 4:02:45 AM UTC-8, [email protected] wrote:
>
> On Fri, Dec 14, 2012 at 2:32 AM, jared <[email protected]<javascript:>> 
> wrote: 
> > I'm having trouble finding a way to check for nested selectors in an 
> view 
> > spec with capybara, which according to this issue doesn't accept a block 
> for 
> > have_selector like webrat. 
> > 
> > There were a couple workarounds with Object#tap given, but neither 
> worked 
> > for me (with capybara 2.0.1 and rspec 2.12.0), and thread hasn't been 
> > updated in a year. 
> > 
> > For clarity, here's what didn't work: 
> > 
> > ... 
> > render 
> > rendered.find("form") do |form| 
> >   form.should have_selector("input") 
> > end 
> > ... 
>
> There's no direct support for nesting, but you can do this: 
>
> rendered.should have_selector("form input") 
>
> HTH, 
> David 
>
> > 
> > Nor did wrapping rendered with Capybara.string as suggested at the 
> bottom of 
> > the thread. 
> > 
> > Seems like a common scenario, can someone explain the correct way to do 
> > this? 
> > 
> > Thanks! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "rspec" group. 
> > To post to this group, send email to [email protected]<javascript:>. 
>
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:>. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/rspec/-/7w5QqXy79y8J. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rspec/-/x9RJfQKx1RsJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to