Hi, all!
I''m writing a functional test and I would like to test if my controller
gives out right content type for an AJAX Request.
Firstly I do
xhr :post, :my_controller, my_params, {''Accept'' =>
''text/javascript''}
to simulate the request, but I don''t know how to write an assertion. I
hoped it would be
assert_equal headers[''Content-Type''],
''text/javascript''
but that turned out to give an error.
Could you please give me a hint for correct syntax?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Do a puts and check the value of header[''Content-Type''] On 3/5/07, Damian Terentyev <threeeyedfish-HPQIj1OAFZMvJsYlp49lxw@public.gmane.org> wrote:> > > Hi, all! > I''m writing a functional test and I would like to test if my controller > gives out right content type for an AJAX Request. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I did it in controller and was very surprised that request.headers are
empty, though I supply them in the test:
xhr :post, :login, my_params, {''Accept'' =>
''text/javascript''}
But my original point was to check them from within the test. And the
test doesn''t have a request or response variable, nor header or
headers. I wished to know how I can access that information from the
test.
On Mar 5, 2007, at 20:52, Bala Paranj wrote:
> Do a puts and check the value of header[''Content-Type'']
>
> On 3/5/07, Damian Terentyev
<threeeyedfish-HPQIj1OAFZMvJsYlp49lxw@public.gmane.org > wrote:
>> Hi, all!
>> I''m writing a functional test and I would like to test if my
>> controller
>> gives out right content type for an AJAX Request.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
If you use the default test that gets generated with your controller, you should be able to access the response headers via the @response.headers hash. On Mar 8, 3:11 pm, Damian Terentyev <threeeyedf...-HPQIj1OAFZMvJsYlp49lxw@public.gmane.org> wrote:> I did it in controller and was very surprised that request.headers are > empty, though I supply them in the test: > > xhr :post, :login, my_params, {''Accept'' => ''text/javascript''} > > But my original point was to check them from within the test. And the > test doesn''t have a request or response variable, nor header or > headers. I wished to know how I can access that information from the > test. > > On Mar 5, 2007, at 20:52, Bala Paranj wrote:> Do a puts and check the value of header[''Content-Type''] > > > On 3/5/07, Damian Terentyev <threeeyedf...-HPQIj1OAFZMvJsYlp49lxw@public.gmane.org > wrote: > >> Hi, all! > >> I''m writing a functional test and I would like to test if my > >> controller > >> gives out right content type for an AJAX Request.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 8, 2007, at 18:40, eden li wrote:> If you use the default test that gets generated with your controller, > you should be able to access the response headers via the > @response.headers hash.Many thanks! Assigning values to @request hash solved my another problem! I am so happy! Yours sincerely, Damian/Three-eyed Fish --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---