[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.

More info here http://rspec.info/documentation/before_and_after.html.
Note
the warning at the bottom of the page.

Regards,
Craig

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs