[rspec-users] [Rspec-Rails] before(:all) doesn't rollback

Bogdan Gusiev agresso at gmail.com
Tue Jul 20 08:24:35 EDT 2010


I don't if this is a bug or feature but if before(:all) create some
persistent objects, these changes doesn't rollback when we get out of the
context.
Here are simplest example to see the issue:

 describe Person do
  context "1" do
    before(:all) do
      Person.create!(@valid_attributes)
    end
    it {
      Person.count.should == 1
    }
  end

  context "2" do
    before(:all) do
      Person.create!(@valid_attributes)
    end
    it {
      Person.count.should == 1
    }
  end
end

One of these two examples always fail because the object created in
before(:all) block of other example won't be clean up.

If it is not a bug then can someone explain why does it work in this way?
My thoughts is that changes made by before(:all) should be rollback after we
get out of scope.
In the same way as before(:each) do.



-- 
Bogdan Gusiev.
agresso at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100720/71239b46/attachment.html>


More information about the rspec-users mailing list