title: Capybara and Rails, Why my link expected to return some thing?
body: <p>I am trying to test that a link dose exist on the page,
  I tried to check all the nesting tags that contain the link tag like that:</p>
  
  <pre><code>response.body.should have_selector("div.page_margins div.page div#nav div.hlist ul li#2")
  </code></pre>
  
  <p>and it passes correctly, but, if I added the link tag to the test like this:</p>
  
  <pre><code>  response.body.should have_selector("div.page_margins div.page div#nav div.hlist ul li#2 a",:text =&gt; "Next")
  </code></pre>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>expected css "div.page_margins div.page div#nav div.hlist ul li#2 a#next_page"
    with text "Next" to return something</p>
  </blockquote>
  
  <p>If I test it with have_link like this:</p>
  
  <pre><code>response.body.should have_link("div.page_margins div.page div#nav div.hlist ul li#2 a#next_page")
  </code></pre>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>expected link "div.page_margins div.page div#nav div.hlist ul li#2
    a#next_page" to return something</p>
  </blockquote>
  
  <p>Can any body help please ? I love rails, but, I still need a hand to get along with testing ..</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is the page.html, I've noticed that the html in content_for in which the link is rendered is not rendered in yield</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"&gt;
  &lt;html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta content="text/html; charset=utf-8" http-equiv="Content-type"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;script src="/assets/application.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css"&gt;
  &lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  var auto_log_off = false;
  //]]&gt;
  &lt;/script&gt;&lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  var student_logged = false;
  //]]&gt;
  &lt;/script&gt;&lt;script src="/assets/sessions.js" type="text/javascript"&gt;&lt;/script&gt;&lt;!-- add your meta tags here --&gt;&lt;link href="/assets/application_yaml/css/my_layout.css" rel="stylesheet" type="text/css"&gt;
  &lt;!--[if lte IE 7]&gt;  &lt;![endif]--&gt;&lt;link href="/assets/application_yaml/css/patch_my_layout.css" rel="stylesheet" type="text/css"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="page_margins"&gt;
  &lt;a href="#dialog" name="modal"&gt;&lt;/a&gt;
  &lt;div id="topnav"&gt;
  &lt;!-- start: skip link navigation --&gt;
  &lt;a class="skip" href="#navigation" title="skip link"&gt;Skip to the navigation&lt;/a&gt;
  &lt;span class="hideme"&gt;.&lt;/span&gt;
  &lt;a class="skip" href="#content" title="skip link"&gt;Skip to the content&lt;/a&gt;
  &lt;span class="hideme"&gt;.&lt;/span&gt;
  &lt;!-- end: skip link navigation --&gt;
  &lt;/div&gt;
  &lt;!-- start: skip link navigation --&gt;
  &lt;!-- end: skip link navigation --&gt;
  &lt;div class="page"&gt;
  &lt;div id="header"&gt;
  &lt;h1&gt;Welcome to course builder!!&lt;/h1&gt;
  &lt;p&gt;&lt;a href="/" id="home_link"&gt;Home&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;div id="nav"&gt;
  &lt;!-- skiplink anchor: navigation --&gt;
  &lt;a id="navigation" name="navigation"&gt;&lt;/a&gt;
  &lt;div class="hlist"&gt;
  &lt;!-- main navigation: horizontal list --&gt;
  
  &lt;div class="quiz_review_buttons"&gt;
  
  &lt;!--
  &lt;ul&gt;
  &lt;li class="active"&gt;&lt;strong&gt;Button 1&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#"&gt;Button 2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#"&gt;Button 3&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  --&gt;
  &lt;/div&gt;
  &lt;!-- &lt;ul&gt; --&gt;
  &lt;!-- &lt;li class="active"&gt;&lt;strong&gt;Button 1&lt;/strong&gt;&lt;/li&gt; --&gt;
  &lt;!-- &lt;li&gt;&lt;a href="#"&gt;Button 2&lt;/a&gt;&lt;/li&gt; --&gt;
  &lt;!-- &lt;li&gt;&lt;a href="#"&gt;Button 3&lt;/a&gt;&lt;/li&gt; --&gt;
  &lt;!-- &lt;li&gt;&lt;a href="#"&gt;Button 4&lt;/a&gt;&lt;/li&gt; --&gt;
  &lt;!-- &lt;li&gt;&lt;a href="#"&gt;Button 5&lt;/a&gt;&lt;/li&gt; --&gt;
  &lt;!-- &lt;/ul&gt; --&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="main"&gt;
  &lt;div id="col1"&gt;
  &lt;div class="clearfix" id="col1_content"&gt;
  &lt;!-- add your content here --&gt;
  
  &lt;div class="debug_div"&gt;
  &lt;p&gt;
  &lt;b&gt;
  devise/sessions#new
  &lt;/b&gt;
  &lt;/p&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="col3"&gt;
  &lt;div class="clearfix" id="col3_content"&gt;
  &lt;!-- add your content here --&gt;
  &lt;div class="alert" id="notice_alert"&gt;You need to sign in or sign up before continuing.&lt;/div&gt;
  &lt;script type="text/javascript"&gt;&lt;/script&gt;&lt;!-- &lt;div style="clear:both"&gt;&lt;/div&gt; --&gt;&lt;h2&gt;Sign in for student&lt;/h2&gt;
  
  &lt;form accept-charset="UTF-8" action="/students/sign_in" class="student_new" id="student_new" method="post"&gt;
  &lt;div style="margin:0;padding:0;display:inline"&gt;&lt;input name="utf8" type="hidden" value="✓"&gt;&lt;/div&gt;
    &lt;div&gt;
  &lt;label for="student_email"&gt;Email&lt;/label&gt;&lt;br&gt;&lt;input id="student_email" name="student[email]" size="30" type="email" value=""&gt;
  &lt;/div&gt;
  
    &lt;div&gt;
  &lt;label for="student_password"&gt;Password&lt;/label&gt;&lt;br&gt;&lt;input id="student_password" name="student[password]" size="30" type="password"&gt;
  &lt;/div&gt;
  
      &lt;div&gt;
  &lt;input name="student[remember_me]" type="hidden" value="0"&gt;&lt;input id="student_remember_me" name="student[remember_me]" type="checkbox" value="1"&gt;&lt;label for="student_remember_me"&gt;Remember me&lt;/label&gt;
  &lt;/div&gt;
  
    &lt;div&gt;&lt;input name="commit" type="submit" value="Sign in"&gt;&lt;/div&gt;
  &lt;/form&gt;
  
    &lt;a href="/students/sign_up"&gt;Sign up&lt;/a&gt;&lt;br&gt;&lt;a href="/students/password/new"&gt;Forgot your password?&lt;/a&gt;&lt;br&gt;
  &lt;/div&gt;
  &lt;!-- IE Column Clearing --&gt;
  &lt;div id="ie_clearing"&gt; &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="footer"&gt;
  Layout based on
  &lt;a href="http://www.yaml.de/"&gt;YAML&lt;/a&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>