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
David Chelimsky
2007-Mar-02 19:09 UTC
[rspec-users] database modifications not rolling back
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 >
On 2 Mar 2007, at 19:09, David Chelimsky wrote:> did you run script/generate rspec?D''oh> > 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.Yes, that did the trick - I feel silly missing that. Thanks David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070302/40eb03c0/attachment.html