Skip to content

Instantly share code, notes, and snippets.

@emschwar
Created August 16, 2011 21:38
Show Gist options
  • Save emschwar/1150242 to your computer and use it in GitHub Desktop.
Save emschwar/1150242 to your computer and use it in GitHub Desktop.
Transactions across before :all with rspec2
require 'spec_helper'
describe "transactions" do
before :all do
@device = Factory(:device)
end
it "has one device before a nested context" do
Device.count.should == 1
end
describe "in a nested context" do
before :all do
@device2 = Factory(:device)
end
it "has two devices" do
Device.count.should == 2
end
end
describe "in another nested context" do
before :all do
@device2 = Factory(:device)
end
it "has two devices" do
Device.count.should == 2
end
end
it "has one device after a nested context" do
Device.count.should == 1
end
end
describe "another top-level example group" do
it "has no devices" do
Device.count.should == 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment