Just sinking my teeth into tests and the going is tough. Is it necessary to define fixtures in my test file (''fixtures :users'')? My test are working with the definition, but I decided to debug and checked for the fixtures existence even without the definition and all of them had been loaded. So what''s the purpose of the declaration? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
yachtman wrote:> Just sinking my teeth into tests and the going is tough.Not as tough as debugging all night before a release. Stick with TDD and you will never look back!> Is it necessary to define fixtures in my test file > (''fixtures :users'')? > > My test are working with the definition, but I decided to debug and > checked for the fixtures existence even without the definition and all > of them had been loaded. So what''s the purpose of the declaration?Of course they are there - you loaded them. However, consider this test suite: class SomeTests ... def test_aardvark screw_users_table_up() assert{ users_table_is_screwed_up() } end def test_zebra deny{ users_table_is_screwed_up() } end end The test case names force [the current version of] test/unit to run those cases in that order. The second test will fail because the first one screwed the table up. The ''fixtures :users'' line means "please un-screw-up the users table between each test case". Adding it to my hypothetical test suite would "fix" it. The fixture system enables "Test Isolation". You could run any test case, in any order, or not at all, and each one should not add any noise to the signal from any other. -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Phlip, Well said. Hadn''t thought of that possibility, that by declaring the fixtures, it would reload them. Smart and makes sense. Thanks!! On Mar 26, 10:08 am, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yachtman wrote: > > Just sinking my teeth into tests and the going is tough. > > Not as tough as debugging all night before a release. Stick with TDD and you > will never look back! > > > Is it necessary to define fixtures in my test file > > (''fixtures :users'')? > > > My test are working with the definition, but I decided to debug and > > checked for the fixtures existence even without the definition and all > > of them had been loaded. So what''s the purpose of the declaration? > > Of course they are there - you loaded them. However, consider this test suite: > > class SomeTests ... > > def test_aardvark > screw_users_table_up() > assert{ users_table_is_screwed_up() } > end > > def test_zebra > deny{ users_table_is_screwed_up() } > end > > end > > The test case names force [the current version of] test/unit to run those cases > in that order. > > The second test will fail because the first one screwed the table up. > > The ''fixtures :users'' line means "please un-screw-up the users table between > each test case". Adding it to my hypothetical test suite would "fix" it. > > The fixture system enables "Test Isolation". You could run any test case, in any > order, or not at all, and each one should not add any noise to the signal from > any other. > > -- > Phlip--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Mar 26, 12:27 am, yachtman <carson.c...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is it necessary to define fixtures in my test file > (''fixtures :users'')? > > My test are working with the definition, but I decided to debug and > checked for the fixtures existence even without the definition and all > of them had been loaded. So what''s the purpose of the declaration?For a while rails apps (by default) have fixtures :all in their test_helper.rb, which does pretty much what you would imagine. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu, Mar 26, 2009 at 8:43 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For a while rails apps (by default) have fixtures :all in their > test_helper.rb, which does pretty much what you would imagine.When I moved an app from 2.2.2 to 2.3.2 a couple days ago, I was prompted to remove the fixtures :all from my test_helper.rb, deprecation warning if I recall correctly. And then removing it broke all my tests. I had to put explicit fixture entries back into in all my tests to get them working again. -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---