[LRUG] Expected response to be a <:redirect>, but was <200> when using should_redirect_to

Matthew Krom matthew.krom at gmail.com
Tue Jul 27 10:02:29 PDT 2010


Hi all  (I replied off-list and Riccardo replied directly to me, but I
believe Riccardo's intention was to email the whole list, so I am
forwarding).

Riccardo, are you using Rails 2.3.6, .7, or .8?  Try it with 2.3.5.  (I've
stayed on 2.3.5 because I saw redirects not happening correctly in the newer
versions).

Matt


On Tue, Jul 27, 2010 at 11:49 AM, Riccardo Tacconi <rtacconi at gmail.com>wrote:

> Thanks to all,
>
> I cleaned the code and used @response and I get the out put:
>
> <html><body>You are being <a href="http://test.host/configurations/25/edit
> ">redirected</a>.</body></html>
>
> So the response is 200 insted of redirecting to
> http://test.host/configurations/25/edit with a 302 status. The strange
> thing is that without Shoulda I get a 302.
>
> On 27 July 2010 16:36, Matthew Krom <matthew.krom at gmail.com> wrote:
>
>> Try response instead of @response (no @ )
>>
>> (off list, because I have not taken the time to read the whole thread)
>>
>> Matthew Krom, principal
>> MW Krom LLC
>> Cambridge, MA
>> +1 617 852 5130
>>
>> On Jul 27, 2010, at 11:33 AM, Riccardo Tacconi <rtacconi at gmail.com>
>> wrote:
>>
>> Yes,
>>
>> That is the order I use. But @response is still nil. I implemented the
>> same test inside a standard Unit::Test and it worked without any error.
>>
>> On 27 July 2010 15:25, Mr Jaba < <the.jaba at gmail.com>the.jaba at gmail.com>wrote:
>>
>>> So it should look something like:
>>>
>>> <http://gist.github.com/492284>http://gist.github.com/492284
>>>
>>>
>>> On 27 July 2010 15:22, Riccardo Tacconi < <rtacconi at gmail.com>
>>> rtacconi at gmail.com> wrote:
>>>
>>>> I already tried that and I get
>>>>
>>>> NoMethodError: undefined method `body' for nil:NilClass
>>>>
>>>> Two days trying to solve this :-(
>>>>
>>>>
>>>> On 27 July 2010 14:58, Mr Jaba < <the.jaba at gmail.com>the.jaba at gmail.com
>>>> > wrote:
>>>>
>>>>> Tim has hit the nail on the head there, there will be no response.body
>>>>> either @response or app.response until you have made the request (the delete
>>>>> line).
>>>>> Move the put down after the delete and try again.
>>>>>
>>>>>
>>>>>
>>>>> On 27 July 2010 14:56, Tim Cowlishaw < <tim at timcowlishaw.co.uk>
>>>>> tim at timcowlishaw.co.uk> wrote:
>>>>>
>>>>>>
>>>>>> On 27 Jul 2010, at 14:43, Riccardo Tacconi wrote:
>>>>>>
>>>>>> On 27 July 2010 13:21, Murray Steele < <murray.steele at gmail.com>
>>>>>> murray.steele at gmail.com> wrote:
>>>>>>
>>>>>>>     should "delete :destroy participations" do
>>>>>>>        app = ApplicationController.new
>>>>>>>       puts app.response.body
>>>>>>>       assert_difference('Participation.count', -1) do
>>>>>>>         delete :destroy, :id => @p.to_param
>>>>>>>       end
>>>>>>>     end
>>>>>>>
>>>>>>>
>>>>>> *Ok, but it does not print anything*
>>>>>>
>>>>>>
>>>>>>
>>>>>> To caveat, I'm not massively familiar with either Test::Unit or
>>>>>> Shoulda, but I can't quite see what this ApplicationController instance
>>>>>> you're creating has to do with the request that your test is making. if you
>>>>>> look in the testing guide: <http://guides.rubyonrails.org/testing.html#functional-tests-for-your-controllers>
>>>>>> http://guides.rubyonrails.org/testing.html#functional-tests-for-your-controllers,
>>>>>> you'll see that the request methods (like delete in your code) populate an
>>>>>> instance variable called @response with the response of the request. try
>>>>>> inspecting the body of this object in order to see what the response of your
>>>>>> request was.
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Tim
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Chat mailing list
>>>>>>  <Chat at lists.lrug.org>Chat at lists.lrug.org
>>>>>>  <http://lists.lrug.org/listinfo.cgi/chat-lrug.org>
>>>>>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Chat mailing list
>>>>>  <Chat at lists.lrug.org>Chat at lists.lrug.org
>>>>>  <http://lists.lrug.org/listinfo.cgi/chat-lrug.org>
>>>>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Riccardo Tacconi
>>>> Web developer at Wolseley UK
>>>>
>>>> <http://www.linkedin.com/in/riccardotacconi>
>>>> http://www.linkedin.com/in/riccardotacconi
>>>>  <http://riccardotacconi.blogspot.com/>
>>>> http://riccardotacconi.blogspot.com/
>>>>  <http://twitter.com/rtacconi>http://twitter.com/rtacconi
>>>> Linux user: #400461
>>>>
>>>> _______________________________________________
>>>> Chat mailing list
>>>>  <Chat at lists.lrug.org>Chat at lists.lrug.org
>>>>  <http://lists.lrug.org/listinfo.cgi/chat-lrug.org>
>>>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Chat mailing list
>>>  <Chat at lists.lrug.org>Chat at lists.lrug.org
>>>  <http://lists.lrug.org/listinfo.cgi/chat-lrug.org>
>>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>>>
>>>
>>
>>
>> --
>> Riccardo Tacconi
>> Web developer at Wolseley UK
>>
>> <http://www.linkedin.com/in/riccardotacconi>
>> http://www.linkedin.com/in/riccardotacconi
>>  <http://riccardotacconi.blogspot.com/>
>> http://riccardotacconi.blogspot.com/
>>  <http://twitter.com/rtacconi>http://twitter.com/rtacconi
>> Linux user: #400461
>>
>> _______________________________________________
>> Chat mailing list
>> Chat at lists.lrug.org
>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>>
>>
>
>
> --
> Riccardo Tacconi
> Web developer at Wolseley UK
>
> http://www.linkedin.com/in/riccardotacconi
> http://riccardotacconi.blogspot.com/
> http://twitter.com/rtacconi
> Linux user: #400461
>



-- 
matthew.krom at gmail.com
MW Krom LLC
Cambridge, MA
617 852 5130
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20100727/e78e34e3/attachment-0003.html>


More information about the Chat mailing list