Bogdan Gusiev
2010-Jul-20 12:24 UTC
[rspec-users] [Rspec-Rails] before(:all) doesn''t rollback
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>
Craig Demyanovich
2010-Jul-20 13:10 UTC
[rspec-users] [Rspec-Rails] before(:all) doesn''t rollback
More info here <http://rspec.info/documentation/before_and_after.html>. Note the warning at the bottom of the page. Regards, Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100720/89a55dc8/attachment.html>