[rspec-users] have_selector only matching immediate descendants in block

David Chelimsky dchelimsky at gmail.com
Wed May 6 11:28:22 EDT 2009


On Wed, May 6, 2009 at 7:14 AM, doug livesey <biot023 at gmail.com> wrote:
> Hi -- I have an expectation that looks like this:
>
>   it "should display a field for the username" do
>     do_render
>     response.should have_selector( "form" ) do |form|
>       form.should have_selector( "input", :name => "username" )
>     end
>   end
>
>
> That gives me this error:
>
>   'session/new.html.haml should display a field for the username' FAILED
>   expected following output to contain a <input name='username'/> tag:
>   <form action="/session" id="login" method="post">
>     <p>
>       <label for="username">
>         Username
>       </label>
>       <input id="username" name="username" type="text"></p>
>     <p>
>       <label for="password">
>         Password
>       </label>
>       <input id="password" name="password" type="password"></p>
>     <input name="commit" type="submit" value="login">
>   </form>
>
> When I don't try to match inside the form (so just saying "response.should
> have_selector( "input" ... )"), it passes fine.
> So is have_selector supposed to only match immediate descendants of the
> selector in the block definition, or is this a bug ...
> ... Or am I being seriously dumb, here? ;)

have_selector is from webrat and there is a separate webrat google
group. Might want to try there, or filing a bug report with webrat:

http://groups.google.com/group/webrat
https://webrat.lighthouseapp.com/

Cheers,
David


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


More information about the rspec-users mailing list