Hi, officially Rails load for each test the fixures file into the database but in my case Rails load the fixures only on the begining of the class and so I get strange side effects. An example: country_test.rb: require File.dirname(__FILE__) + ''/../test_helper'' class CountryTest < Test::Unit::TestCase fixtures :countries def test_should_destroy assert_equal 2, Country.count Country.find(:first).destroy assert_equal 1, Country.count end def test_should_have_2_entries assert_equal 2, Country.count end end countries.yml: germany: code: DE name: Germany japan: code: JP name: Japan Error message: 1) Failure: test_should_have_2_fixtures(CountryTes... [test/unit/country_test.rb:22]: <2> expected but was <1>. 2 tests, 3 assertions, 1 failures, 0 errors Know anybody this phenomenon or make I a misstake? Eddy -- 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 -~----------~----~----~----~------~----~------~--~---
On 28 May 2008, at 09:59, Eddy Betara wrote:> > Hi, > > officially Rails load for each test the fixures file into the database > but in my case Rails load the fixures only on the begining of the > class > and so I get strange side effects. An example:It sounds like you''ve got transactional fixtures on (which means that for speed reasons rails doesn''t reload fixtures, but wraps tests in a transaction that is rolled back) but that your database doesn''t support transactions (which usually means mysql with myisam tables) Fred> > > country_test.rb: > require File.dirname(__FILE__) + ''/../test_helper'' > > class CountryTest < Test::Unit::TestCase > fixtures :countries > > def test_should_destroy > assert_equal 2, Country.count > Country.find(:first).destroy > assert_equal 1, Country.count > end > > def test_should_have_2_entries > assert_equal 2, Country.count > end > > end > > countries.yml: > germany: > code: DE > name: Germany > japan: > code: JP > name: Japan > > Error message: > 1) Failure: > test_should_have_2_fixtures(CountryTes... > [test/unit/country_test.rb:22]: > <2> expected but was > <1>. > > 2 tests, 3 assertions, 1 failures, 0 errors > > Know anybody this phenomenon or make I a misstake? > > Eddy > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 28 May 2008, at 09:59, Eddy Betara wrote: > >> >> Hi, >> >> officially Rails load for each test the fixures file into the database >> but in my case Rails load the fixures only on the begining of the >> class >> and so I get strange side effects. An example: > > It sounds like you''ve got transactional fixtures on (which means that > for speed reasons rails doesn''t reload fixtures, but wraps tests in a > transaction that is rolled back) but that your database doesn''t > support transactions (which usually means mysql with myisam tables) > > FredYou are my man! Thanks!!! With InnoDB as storage engine it works. Many thanks, Eddy -- 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 -~----------~----~----~----~------~----~------~--~---