<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,6 +4,8 @@ module Spec
 
       class RedirectTo  #:nodoc:
 
+        include ActionController::StatusCodes
+
         def initialize(request, expected)
           @expected = expected
           @request = request
@@ -13,12 +15,20 @@ module Spec
           @redirected = response.redirect?
           @actual = response.redirect_url
           return false unless @redirected
+
+          if @expected_status
+            @actual_status = interpret_status(response.code.to_i)
+            @status_matched = @expected_status == @actual_status
+          else
+            @status_matched = true
+          end
+
           if @expected.instance_of? Hash
             return false unless @actual =~ %r{^\w+://#{@request.host}}
             return false unless actual_redirect_to_valid_route
-            return actual_hash == expected_hash
+            return actual_hash == expected_hash &amp;&amp; @status_matched
           else
-            return @actual == expected_url
+            return @actual == expected_url &amp;&amp; @status_matched
           end
         end
 
@@ -48,6 +58,11 @@ module Spec
           QueryParameterParser.parse_query_parameters(query, @request)
         end
 
+        def with(options)
+          @expected_status = interpret_status(options[:status])
+          self
+        end
+        
        def expected_url
           case @expected
             when Hash
@@ -63,7 +78,11 @@ module Spec
 
         def failure_message
           if @redirected
-            return %Q{expected redirect to #{@expected.inspect}, got redirect to #{@actual.inspect}}
+            if @status_matched
+              return %Q{expected redirect to #{@expected.inspect}, got redirect to #{@actual.inspect}}
+            else
+              return %Q{expected redirect to #{@expected.inspect} with status #{@expected_status}, got #{@actual_status}}
+            end
           else
             return %Q{expected redirect to #{@expected.inspect}, got no redirect}
           end</diff>
      <filename>lib/spec/rails/matchers/redirect_to.rb</filename>
    </modified>
    <modified>
      <diff>@@ -62,5 +62,9 @@ class RedirectSpecController &lt; ApplicationController
   def action_to_redirect_to_action_with_method_restriction
     redirect_to :action =&gt; 'action_with_method_restriction'
   end
+
+  def action_with_redirect_to_somewhere_with_status
+    redirect_to :action =&gt; 'somewhere', :status =&gt; 301
+  end
 end
 </diff>
      <filename>spec/resources/controllers/redirect_spec_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -87,6 +87,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
       response.should redirect_to(&quot;http://test.host/nonexistant/none&quot;)
     end
 
+    it &quot;redirected to a URL with a specific status code&quot; do
+      get &quot;action_with_redirect_to_somewhere_with_status&quot;
+      response.should redirect_to(:action =&gt; 'somewhere').with(:status =&gt; 301)
+    end
+    
+    it &quot;redirected to a URL with a specific status code (using names)&quot; do
+      get &quot;action_with_redirect_to_somewhere_with_status&quot;
+      response.should redirect_to(:action =&gt; 'somewhere').with(:status =&gt; :moved_permanently)
+    end
+
   end
 
   
@@ -147,6 +157,20 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
         response.should redirect_to(:action =&gt; 'somewhere_else')
       }.should fail_with(&quot;expected redirect to {:action=&gt;\&quot;somewhere_else\&quot;}, got redirect to \&quot;http://test.host/redirect_spec/somewhere\&quot;&quot;)
     end
+
+    it &quot;redirected with wrong status code&quot; do
+      get 'action_with_redirect_to_somewhere_with_status'
+      lambda {
+        response.should redirect_to(:action =&gt; 'somewhere').with(:status =&gt; 302)
+      }.should fail_with(&quot;expected redirect to {:action=&gt;\&quot;somewhere\&quot;} with status 302 Found, got 301 Moved Permanently&quot;)
+    end
+    
+    it &quot;redirected with wrong status code (using names)&quot; do
+      get 'action_with_redirect_to_somewhere_with_status'
+      lambda {
+        response.should redirect_to(:action =&gt; 'somewhere').with(:status =&gt; :found)
+      }.should fail_with(&quot;expected redirect to {:action=&gt;\&quot;somewhere\&quot;} with status 302 Found, got 301 Moved Permanently&quot;)
+    end
     
     it &quot;redirected to incorrect path with leading /&quot; do
       get 'action_with_redirect_to_somewhere'</diff>
      <filename>spec/spec/rails/matchers/redirect_to_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>466323c4834aa29b636a1f791f48fa56108139dc</id>
    </parent>
  </parents>
  <author>
    <name>Damian Janowski</name>
    <email>damian.janowski@gmail.com</email>
  </author>
  <url>http://github.com/dchelimsky/rspec-rails/commit/36fadd6d7585f1dcc048185a93745e0c4ace99c1</url>
  <id>36fadd6d7585f1dcc048185a93745e0c4ace99c1</id>
  <committed-date>2009-01-11T20:05:59-08:00</committed-date>
  <authored-date>2008-10-20T05:40:24-07:00</authored-date>
  <message>Adding status codes to redirect_to matcher.

[#570 state:resolved]</message>
  <tree>826b3548e6d7d2005a39db6d8a8991262c434613</tree>
  <committer>
    <name>David Chelimsky</name>
    <email>dchelimsky@gmail.com</email>
  </committer>
</commit>
