I started using the new Model.should_have(1).records expectation in rspec_on_rails, and quickly realized that my fixtures were remaining loaded, even in contexts that didn''t use them. Bug or feature? Jay Levitt
On 10/17/06, Jay Levitt <lists-rspec at shopwatch.org> wrote:> I started using the new Model.should_have(1).records expectation in > rspec_on_rails, and quickly realized that my fixtures were remaining > loaded, even in contexts that didn''t use them. Bug or feature? >Looks like a bug. I reproduced this by standing in rspec_on_rails and running: spec spec/models/person_spec.rb -s "A new Person" ; echo "select * from people;" | sqlite3 db/test.db It prints out the following at the end: 1|Lachie I put some debug statements in AR''s fixtures.rb#teardown_with_fixtures right before ActiveRecord::Base.connection.rollback_db_transaction. And the rollback is definitely being executed. So I''m inclined to think this is a Rails bug with sqlite3. I haven''t tried with Test::Unit to see if it behaves the same way. What Rails version and what database are you using? Aslak> Jay Levitt > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 10/17/06, Jay Levitt <lists at shopwatch.org> wrote:> aslak hellesoy wrote: > > So I''m inclined to think this is a Rails bug with sqlite3. > > I haven''t tried with Test::Unit to see if it behaves the same way.I tried with Test::Unit in RSpec''s vendor/rspec_on_rails: 1) Get the latest svn trunk 2) cd vendor/rspec_on_rails 3) rake db:migrate db:test:clone ; ruby test/unit/animal_test.rb ; echo "select * from animals;" | sqlite3 db/test.db I get: 1 tests, 1 assertions, 0 failures, 0 errors 1|Pig|1 2|Horse|1 The records are left in the database - even with Test::Unit and transactional fixtures ON. I''d say it''s a Rails bug (I''ve tried both bleeding edge and 1.1.6). To be 100% sure - could you please try to run a Test::Unit test in your app and see how it works with that? Cheers, Aslak> > > > What Rails version and what database are you using? > > Older edge rails (4913) and PostgreSQL 8.1. > > Jay > >
aslak hellesoy wrote:> On 10/17/06, Jay Levitt <lists at shopwatch.org> wrote: >> aslak hellesoy wrote: >>> So I''m inclined to think this is a Rails bug with sqlite3. >>> I haven''t tried with Test::Unit to see if it behaves the same way. > > I tried with Test::Unit in RSpec''s vendor/rspec_on_rails: > 1) Get the latest svn trunk > 2) cd vendor/rspec_on_rails > 3) rake db:migrate db:test:clone ; ruby test/unit/animal_test.rb ; > echo "select * from animals;" | sqlite3 db/test.db > > I get: > > 1 tests, 1 assertions, 0 failures, 0 errors > 1|Pig|1 > 2|Horse|1 > > The records are left in the database - even with Test::Unit and > transactional fixtures ON. > > I''d say it''s a Rails bug (I''ve tried both bleeding edge and 1.1.6). To > be 100% sure - could you please try to run a Test::Unit test in your > app and see how it works with that?Actually, I''ve just read an article from back when transactional fixtures first came out, and it seems that this is by design; Rails commits the fixtures to disk so that it can keep rolling back to that point. Ah, well. I suppose I prefer to search for the specific records I''ve created, not just count the total records, so this will stop me from being lazy! See: http://clarkware.com/cgi/blosxom/2005/10/24