Hi, How do you get the rendered output (sent to the browser) in a controller functional test? I searched for this, and tried things like @content_for_layout @response.template.content_for_layout yield yield :layout CmdJohnson --~--~---------~--~----~------------~-------~--~----~ 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
2009-Mar-14 12:45 UTC
Re: How to get controller output in functional test
On Mar 14, 11:24 am, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > How do you get the rendered output (sent to the browser) in a controller > functional test?Have a look at @response.body Fred> > I searched for this, and tried things like > > @content_for_layout > @response.template.content_for_layout > yield > yield :layout > > CmdJohnson--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Commander Johnson
2009-Mar-14 13:29 UTC
Re: How to get controller output in functional test
@response.body is an empty string! With the debugger, I can find @response.template.content_for_layout but that''s not accessible with a method call. This is the controller code: respond_to do |format| format.html end On Sat, Mar 14, 2009 at 1:45 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Mar 14, 11:24 am, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Hi, > > > > How do you get the rendered output (sent to the browser) in a controller > > functional test? > > Have a look at @response.body > > Fred > > > > I searched for this, and tried things like > > > > @content_for_layout > > @response.template.content_for_layout > > yield > > yield :layout > > > > CmdJohnson > > >--~--~---------~--~----~------------~-------~--~----~ 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
2009-Mar-14 14:35 UTC
Re: How to get controller output in functional test
On Mar 14, 1:29 pm, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> @response.body is an empty string!Are you checking this after the call to the controller has been made ? Fred> With the debugger, I can find @response.template.content_for_layout but > that''s not accessible with a method call. > > This is the controller code: > > respond_to do |format| > format.html > end > > On Sat, Mar 14, 2009 at 1:45 PM, Frederick Cheung < > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Mar 14, 11:24 am, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > Hi, > > > > How do you get the rendered output (sent to the browser) in a controller > > > functional test? > > > Have a look at @response.body > > > Fred > > > > I searched for this, and tried things like > > > > @content_for_layout > > > @response.template.content_for_layout > > > yield > > > yield :layout > > > > CmdJohnson--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Commander Johnson
2009-Mar-14 14:41 UTC
Re: How to get controller output in functional test
Yes, like this: get :reload puts "@response.body: [#{@response.body}]" Results in: @response.body: [] On Sat, Mar 14, 2009 at 3:35 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Mar 14, 1:29 pm, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > @response.body is an empty string! > > Are you checking this after the call to the controller has been made ? > > Fred > > With the debugger, I can find @response.template.content_for_layout but > > that''s not accessible with a method call. > > > > This is the controller code: > > > > respond_to do |format| > > format.html > > end > > > > On Sat, Mar 14, 2009 at 1:45 PM, Frederick Cheung < > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Mar 14, 11:24 am, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > Hi, > > > > > > How do you get the rendered output (sent to the browser) in a > controller > > > > functional test? > > > > > Have a look at @response.body > > > > > Fred > > > > > > I searched for this, and tried things like > > > > > > @content_for_layout > > > > @response.template.content_for_layout > > > > yield > > > > yield :layout > > > > > > CmdJohnson > > >--~--~---------~--~----~------------~-------~--~----~ 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
2009-Mar-14 17:20 UTC
Re: How to get controller output in functional test
On Mar 14, 2:41 pm, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes, like this: > get :reload > > puts "@response.body: [#...@response.body}]" > > Results in: > > @response.body: [] >To me that sounds like the response is actually empty. Fred> On Sat, Mar 14, 2009 at 3:35 PM, Frederick Cheung < > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Mar 14, 1:29 pm, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > @response.body is an empty string! > > > Are you checking this after the call to the controller has been made ? > > > Fred > > > With the debugger, I can find @response.template.content_for_layout but > > > that''s not accessible with a method call. > > > > This is the controller code: > > > > respond_to do |format| > > > format.html > > > end > > > > On Sat, Mar 14, 2009 at 1:45 PM, Frederick Cheung < > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Mar 14, 11:24 am, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > wrote: > > > > > Hi, > > > > > > How do you get the rendered output (sent to the browser) in a > > controller > > > > > functional test? > > > > > Have a look at @response.body > > > > > Fred > > > > > > I searched for this, and tried things like > > > > > > @content_for_layout > > > > > @response.template.content_for_layout > > > > > yield > > > > > yield :layout > > > > > > CmdJohnson--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Commander Johnson
2009-Mar-15 12:19 UTC
Re: How to get controller output in functional test
I found the problem. Goldberg is used to generate the page title, but generated an error in test mode. A quick fix was to return an empty layout in test mode. On Sat, Mar 14, 2009 at 6:20 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Mar 14, 2:41 pm, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Yes, like this: > > get :reload > > > > puts "@response.body: [#...@response.body}]" > > > > Results in: > > > > @response.body: [] > > > To me that sounds like the response is actually empty. > > Fred > > On Sat, Mar 14, 2009 at 3:35 PM, Frederick Cheung < > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Mar 14, 1:29 pm, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > @response.body is an empty string! > > > > > Are you checking this after the call to the controller has been made ? > > > > > Fred > > > > With the debugger, I can find @response.template.content_for_layout > but > > > > that''s not accessible with a method call. > > > > > > This is the controller code: > > > > > > respond_to do |format| > > > > format.html > > > > end > > > > > > On Sat, Mar 14, 2009 at 1:45 PM, Frederick Cheung < > > > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > On Mar 14, 11:24 am, Commander Johnson <commanderjohn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > > > > > wrote: > > > > > > Hi, > > > > > > > > How do you get the rendered output (sent to the browser) in a > > > controller > > > > > > functional test? > > > > > > > Have a look at @response.body > > > > > > > Fred > > > > > > > > I searched for this, and tried things like > > > > > > > > @content_for_layout > > > > > > @response.template.content_for_layout > > > > > > yield > > > > > > yield :layout > > > > > > > > CmdJohnson > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---