title: Testing view helpers in Rails with RSpec
body: <p>I need to test the following helper:</p>
  
  <pre><code>def display_all_courses
    @courses = Course.all
  
    output =  ""
  
    for course in @courses do
      output &lt;&lt; content_tag(:li, :id =&gt; course.title.gsub(" ", "-").downcase.strip) do
        concat content_tag(:h1, course.title)
        concat link_to("Edit", edit_course_path(course))
      end
    end
  
    return output
  end 
  </code></pre>
  
  <p>and I'm wondering if there is a way that I can test the output of this.  Basically, I just want to test that the helper gets me the correct number of li elements, and maybe the case when there aren't any courses.  </p>
  
  <p>My first thought is to do something like this:</p>
  
  <pre><code>describe DashboardHelper do
    describe display_all_courses do
      it "should return an list of all the courses" do
        7.times{Factory(:course)
        html = helper.display_all_courses
        html.should have_selector(:li)
      end
    end
  end
  </code></pre>
  
  <p>and this works just fine.  However, if I add the :count option to the have_selector call it suddenly fails, can anybody help me figure out why that is?</p>