title: RSpec should redirect_to problem
body: <p>I'm writing a spec for my Rails controller, this is the action I'm testing:</p>
  <pre><code>def create
    @course = Course.new(params[:course])
    if @course.save then
      #flash[:notice] = 'Course Created'
      redirect_to courses_path
    else
      render :action =&gt; 'new', :status =&gt; 400
    end
  end
  </code></pre>
  <p>And this is the spec that validates it:</p>
  <pre><code>describe &quot;POST /courses [Good Input]&quot; do
  
    it &quot;should redirect to Courses index page after creation&quot; do
      @course.stub!(:save).and_return(true)
      post :create
      response.should be_success
      response.should redirect_to(courses_path)
    end
  
  end
  </code></pre>
  <p>Still I'm getting this error from RSpec:</p>
  <blockquote>
  <p>'CoursesController POST /courses [Good
  Input]</p>
  <p>should redirect to Courses
  index page after creation'</p>
  </blockquote>
  <p><strong>FAILED</strong></p>
  <blockquote>
  <p>expected redirect to &quot;/courses&quot;, got
  no redirect</p>
  </blockquote>
  <p>Any ideas why this happens?</p>
  <p><strong>SOLVED</strong></p>
  <p>as <strong>rishavrastogi</strong> stated, <em>should be_success</em> expects a http code on the 2xx range, and a redirect falls into the 3xx range (actually its 302)</p>
  <p>The assertion needs to be changed to =&gt; <em>response.should be_redirect</em>.</p>
  <p>Although in this case, it's redundant to check that the response is a redirect and then checking that redirects to an specific page, so that assertion is not needed anymore.</p>