Hi List I have a controller method that I would like to render some objects as XML, using the following: render :xml => @goals Is there anyway in RSpec to check that the controller is indeed rendering xml? Rory --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-May-19 07:44 UTC
Re: RSpec - how to validate that controller renders xml
Is this a conditional render call or does the action always render xml? It will always render xml if you tell it to, and you don''t need to test Rails; it''s already been tested. On Mon, May 19, 2008 at 5:12 PM, Rory McKinley <rorymckinleylists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi List > > I have a controller method that I would like to render some objects as > XML, using the following: > > render :xml => @goals > > Is there anyway in RSpec to check that the controller is indeed > rendering xml? > > Rory > > > >-- Appreciated my help? Reccommend me on Working With Rails http://workingwithrails.com/person/11030-ryan-bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-19 08:16 UTC
Re: RSpec - how to validate that controller renders xml
On 19 May 2008, at 08:44, Ryan Bigg (Radar) wrote:> Is this a conditional render call or does the action always render > xml? It will always render xml if you tell it to, and you don''t need > to test Rails; it''s already been tested. >That said, you could always check @response.content_type Fred> On Mon, May 19, 2008 at 5:12 PM, Rory McKinley <rorymckinleylists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > wrote: > > Hi List > > I have a controller method that I would like to render some objects as > XML, using the following: > > render :xml => @goals > > Is there anyway in RSpec to check that the controller is indeed > rendering xml? > > Rory > > > > > > -- > Appreciated my help? > Reccommend me on Working With Rails > http://workingwithrails.com/person/11030-ryan-bigg > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rory McKinley
2008-May-19 08:40 UTC
Re: RSpec - how to validate that controller renders xml
Frederick Cheung wrote:> > On 19 May 2008, at 08:44, Ryan Bigg (Radar) wrote: > >> Is this a conditional render call or does the action always render >> xml? It will always render xml if you tell it to, and you don''t need >> to test Rails; it''s already been tested. >> > That said, you could always check @response.content_type<snip> Thanks Frederick and Ryan To answer Ryan''s question: Currently, it will always render xml, but I am trying to do BDD and writing my specs first, therefore I am putting the spec in to force myself to remember to render as xml, rather than checking rails ;) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-May-19 09:43 UTC
Re: RSpec - how to validate that controller renders xml
I didn''t know about that @response.content_type, thanks Fred! Also, isn''t it response, not @response? On Mon, May 19, 2008 at 6:10 PM, Rory McKinley <rorymckinleylists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Frederick Cheung wrote: > > > > On 19 May 2008, at 08:44, Ryan Bigg (Radar) wrote: > > > >> Is this a conditional render call or does the action always render > >> xml? It will always render xml if you tell it to, and you don''t need > >> to test Rails; it''s already been tested. > >> > > That said, you could always check @response.content_type > <snip> > > Thanks Frederick and Ryan > > To answer Ryan''s question: > > Currently, it will always render xml, but I am trying to do BDD and > writing my specs first, therefore I am putting the spec in to force > myself to remember to render as xml, rather than checking rails ;) > > > >-- Appreciated my help? Reccommend me on Working With Rails http://workingwithrails.com/person/11030-ryan-bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-19 10:08 UTC
Re: RSpec - how to validate that controller renders xml
On 19 May 2008, at 10:43, Ryan Bigg (Radar) wrote:> I didn''t know about that @response.content_type, thanks Fred! > > Also, isn''t it response, not @response?Not as far as I know. Fred> > > On Mon, May 19, 2008 at 6:10 PM, Rory McKinley <rorymckinleylists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > wrote: > > Frederick Cheung wrote: > > > > On 19 May 2008, at 08:44, Ryan Bigg (Radar) wrote: > > > >> Is this a conditional render call or does the action always render > >> xml? It will always render xml if you tell it to, and you don''t > need > >> to test Rails; it''s already been tested. > >> > > That said, you could always check @response.content_type > <snip> > > Thanks Frederick and Ryan > > To answer Ryan''s question: > > Currently, it will always render xml, but I am trying to do BDD and > writing my specs first, therefore I am putting the spec in to force > myself to remember to render as xml, rather than checking rails ;) > > > > > > -- > Appreciated my help? > Reccommend me on Working With Rails > http://workingwithrails.com/person/11030-ryan-bigg > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rory McKinley
2008-May-19 10:30 UTC
Re: RSpec - how to validate that controller renders xml
Frederick Cheung wrote:> > On 19 May 2008, at 10:43, Ryan Bigg (Radar) wrote: > >> I didn''t know about that @response.content_type, thanks Fred! >> >> Also, isn''t it response, not @response? > > Not as far as I know. > > Fred<snip> Plain old response seems to work for me. Does anybody know if there is some place where the response methods are documented (e..g response.code, response.content_type etc) ? --~--~---------~--~----~------------~-------~--~----~ 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 normally test XML and JSON responses using something like http://pastie.caboo.se/199453 On May 19, 11:30 am, Rory McKinley <rorymckinleyli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Frederick Cheung wrote: > > > On 19 May 2008, at 10:43, Ryan Bigg (Radar) wrote: > > >> I didn''t know about that @response.content_type, thanks Fred! > > >> Also, isn''t it response, not @response? > > > Not as far as I know. > > > Fred > > <snip> > Plain old response seems to work for me. Does anybody know if there is > some place where the response methods are documented (e..g > response.code, response.content_type etc) ?--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rory McKinley wrote:> Plain old response seems to work for me. Does anybody know if there is > some place where the response methods are documented (e..g > response.code, response.content_type etc) ?ActionController::AbstractResponse --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daniel Spaniel
2009-Oct-15 22:57 UTC
Re: RSpec - how to validate that controller renders xml
Nice code in the pastie Very helpful. Thanks. Spongy wrote:> I normally test XML and JSON responses using something like > http://pastie.caboo.se/199453 > > On May 19, 11:30�am, Rory McKinley <rorymckinleyli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>-- Posted via http://www.ruby-forum.com/.