[rspec-users] redirection doesn't get detected well?

Michael Trier mtrier at eminentconsultinggroup.com
Wed Apr 11 18:10:58 EDT 2007


I ran into a similar issue due to the same issue and blogged about it  
here: http://blog.railsconsulting.com/2007/3/27/mocking-restful-routes

I was going to originally respond to you and suggest that but since  
the first test didn't fail it threw me once again.

Michael

On Apr 11, 2007, at 5:58 PM, Matthijs Langenberg wrote:

> Thanks for the hint David, when I looked at response.body I saw the
> following HTML passing by:
>
> <pre>OrderProduct expected :find with (:first, {:conditions=>
> {:order_id=>3, :product_id=>6}}) but received it with (:first,
> {:conditions=>{:order_id=>"3", :product_id=>"6"}})</pre>
>
> Which makes totally sense since params["order_id"] and
> params["product_id"] indeed are String objects instead of Fixnum
> objects, however, shouldn't this expectation error raise earlier and
> make that expectation fail instead of the response.should be_redirect
> expectation?
>
> On 4/11/07, David Chelimsky <dchelimsky at gmail.com> wrote:
>> On 4/11/07, Matthijs Langenberg <mlangenberg at gmail.com> wrote:
>>> I'm doing a redirect in one of my controller actions and somehow  
>>> I can't
>>> spec it, see this pastie: http://pastie.caboo.se/53120.
>>> When following the link from a browser I'm being redirected to  
>>> the right
>>> page.
>>
>> First of all - nice example!
>>
>> Secondly, this looks like it should work. What's actually in the  
>> response?
>>
>> ...
>> it "should destroy order_product with order_id==3 and product_id==6
>> and redirect to /orders/3." do
>>     @order_product.should_receive(:destroy)
>>     delete 'destroy', :id => 'nil', :order_id => 3, :product_id => 6
>>     puts response.inspect
>>     response.should be_redirect
>>   end
>> ...
>>
>>>
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list