wbsmith83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-02 14:32 UTC
Code works in console but fails test?
So I have message model and each user has many messages. When I run user.messages in the console it returns correctly, however in the test it returns and empty collection? Any thoughts. All the sql is being generate correctly, I checked the log. Here''s a pastie with the code in question. http://pastie.caboo.se/84337 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, please post the exact statement that you''re typing in the console. -Conrad On 8/2/07, wbsmith83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <wbsmith83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > So I have message model and each user has many messages. When I run > user.messages in the console it returns correctly, however in the test > it returns and empty collection? Any thoughts. All the sql is being > generate correctly, I checked the log. Here''s a pastie with the code > in question. > > http://pastie.caboo.se/84337 > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
wbsmith83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-02 15:05 UTC
Re: Code works in console but fails test?
u = User.find :first then u.messages.size the output is three On Aug 2, 9:42 am, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, please post the exact statement that you''re typing in the console. > -Conrad > > On 8/2/07, wbsmit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <wbsmit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > So I have message model and each user has many messages. When I run > > user.messages in the console it returns correctly, however in the test > > it returns and empty collection? Any thoughts. All the sql is being > > generate correctly, I checked the log. Here''s a pastie with the code > > in question. > > >http://pastie.caboo.se/84337--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
tests are run against the test database, so it will be empty unless you create some messages for your user in fixtures or otherwise. On Aug 2, 10:32 am, "wbsmit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wbsmit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So I have message model and each user has many messages. When I run > user.messages in the console it returns correctly, however in the test > it returns and empty collection? Any thoughts. All the sql is being > generate correctly, I checked the log. Here''s a pastie with the code > in question. > > http://pastie.caboo.se/84337--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---