[rspec-users] database modifications not rolling back

David Chelimsky dchelimsky at gmail.com
Fri Mar 2 14:09:01 EST 2007


did you run script/generate rspec?

There's a new structure in spec_helper.rb.

You may need to blow away your test db and recreate it because you've
added records to it now.

Please let us know if that does the trick.

Cheers,
David

On 3/2/07, David Smalley <david.smalley.lists at googlemail.com> wrote:
> Hi,
>
> Since moving  this morning from 0.7.5.1 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 0.7.5.1 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 0.7.5.1 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.
>
>
> spec_helper.rb
>
> module CompetitionSpecHelper
>    def new_competition
>       code_to_create_a_new_competition
>       return the competition
>    end
> end
>
>
> competition_spec.rb
>
> require File.dirname(__FILE__) + '/../spec_helper'
>
> context "Given a visible competition" do
>    include CompetitionSpecHelper
>
>    setup do
>      @competition = new_competition
>      @competition.process!
>    end
>
>    specify "should return true for started?" do
>      @competition.started? should == true
>    end
> ......................
>
>
> 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.
>
> Thanks,
>
> David
>
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list