this is odd.. not my first time writing tests, but i have the records in my test fixtures labelled so i can just use the instance variable ''@label'' in my tests. worked fine in my other rails project, but i get nil errors now.. when i put @label = Table.find(1) in the setup method things work fine.. any idea why my fixture data is getting auto-loaded into the intance vars? thanks in advance, Stuart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2006-Nov-09 18:37 UTC
Re: unit test: fixutres not getting loaded into instance vars
That method of dealing with fixtures is deprecated and should not be used. It might even be gone now for you. Proper use of fixures: fixture_type(:fixture_name) So in your case table(:label) Jason On 11/9/06, stewbawka <stewbawka-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > this is odd.. not my first time writing tests, but i have the records > in my test fixtures labelled so i can just use the instance variable > ''@label'' in my tests. worked fine in my other rails project, but i get > nil errors now.. when i put @label = Table.find(1) in the setup method > things work fine.. any idea why my fixture data is getting auto-loaded > into the intance vars? > > thanks in advance, > > Stuart > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
stewbawka
2006-Nov-09 20:35 UTC
Re: unit test: fixutres not getting loaded into instance vars
well it works now.. but one more thing: usually the table that the fixture is from gets cleared out after the test.. right now after the test is done i can go into the test database and still see records in it.. things seem very different. don''t know why --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Instanciated fixtures (fixtures appearing as instance variables) can be turned on/off (default now off as it is slower) from your test_helper Transactional fixtures are now on by default (because it''s faster), however if you''re using a db that doesn''t do transactions (eg MySQL with MyISAM tables then that won''t work), which would explains the changes made during tests persisting. Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---