I create a number of users in a database through a fixture. I then run a unit test to verify that the number of users in the database is correct. I want to make this number a constant that is only defined in one place. I currently have it defined in ./test/test_helper.rb which works fine for the unit test, but the fixture cannot see it. I''ve tried to "require ''../test_helper.rb'' " from inside the fixture to no avail. Any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bob Showalter
2007-Sep-27 16:26 UTC
Re: using a constant in both unit tests and in fixtures
On 9/26/07, Ryan Angilly <angilly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I create a number of users in a database through a fixture. I then run a > unit test to verify that the number of users in the database is correct. I > want to make this number a constant that is only defined in one place. I > currently have it defined in ./test/test_helper.rb which works fine for the > unit test, but the fixture cannot see it. I''ve tried to "require > ''../test_helper.rb'' " from inside the fixture to no avail.You can put it in a file in lib/ and then require that file from both your test and your fixture file. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---