Forum: RSpec have_selector only matching immediate descendants in block

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Doug L. (Guest)
on 2009-05-06 18:19
(Received via mailing list)
Hi -- I have an expectation that looks like this:

  it "should display a field for the username" do
    response.should have_selector( "form" ) do |form|
      form.should have_selector( "input", :name => "username" )

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">
      <label for="username">
      <input id="username" name="username" type="text"></p>
      <label for="password">
      <input id="password" name="password" type="password"></p>
    <input name="commit" type="submit" value="login">

When I don't try to match inside the form (so just saying
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? ;)
Cheers, Doug.
David C. (Guest)
on 2009-05-06 19:33
(Received via mailing list)
On Wed, May 6, 2009 at 7:14 AM, doug livesey 
<removed_email_address@domain.invalid> wrote:
> That gives me this error:
>       <label for="password">
> ... 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:

Doug L. (Guest)
on 2009-05-06 20:28
(Received via mailing list)
Will do -- cheers!

2009/5/6 David C. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.