[rspec-users] ordering dependency in tests?

Fearless Fool lists at ruby-forum.com
Thu Feb 24 13:36:48 EST 2011


A little additional information: every time I run the tests, it creates 
a new PremiseGroup model.  Shouldn't the db get rolled back between 
tests?

Here is PremiseGroup, listed here in its entirety:

  class PremiseGroup < ActiveRecord::Base
    has_many :premise_group_members, :dependent => :destroy
    has_many :premises, :through => :premise_group_members
    RESIDENTIAL = self.create(:name => "residential")
  end

When I put in a debugging statement:

  before(:each) do
    $stderr.puts("PremiseGroup count = #{PremiseGroup.count}"
  end

... it reports that there are 151 PremiseGroups, then 152 on the next 
run, then 153 on the next.  Naturally, calling 'rake db:test:prepare' 
resets it, but shouldn't the database be rolled back between tests 
regardless?  I'm not 100% sure this is the cause of my problems, but it 
smells like it...

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list