[rspec-users] database modifications not rolling back

David Smalley david.smalley.lists at googlemail.com
Fri Mar 2 13:18:58 EST 2007


Since moving  this morning from to 0.8.2 I've hit some  
problems and I'm not sure if it's something I'm doing wrong or a  
change in 0.8.2

Basically I dislike fixtures so I have been using a helper method to  
create an object I need frequently and setting it up in the setup  
method, in this all worked fine - but since moving to 0.8.2  
I'm finding that the records are not removed from the database after  
each spec, leading to a failure on the next attempt to create the  
identical record (there is some uniqueness validation on the model).  
After all tests have finished the test database is populated entirely  
with all the records I have created, whereas on I'd find this  
database completely empty on completion.

FYI - I'm using Rspec 0.8.2 with matching revision of rspec_on_rails,  
Rails 1.2.2 and Mysql.


module CompetitionSpecHelper
   def new_competition
      return the competition


require File.dirname(__FILE__) + '/../spec_helper'

context "Given a visible competition" do
   include CompetitionSpecHelper

   setup do
     @competition = new_competition

   specify "should return true for started?" do
     @competition.started? should == true

Is there something wrong with what I have been doing? All tests were  
passing before the upgrade, it'll take me a while to go through and  
change to fixtures if this isn't the correct way to do it. I had seen  
numerous discussion around Rspec that seemed to validate the way I've  
been doing things, in spirit at least.



More information about the rspec-users mailing list