Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / examples / before_and_after_example.rb
blob09e3805fb5a25165446856173d6cef21fdcd26ef
1 $global = 0
3 describe "State created in before(:all)" do
4   before :all do
5     @sideeffect = 1
6     $global +=1
7   end
9   before :each do
10     @isolated = 1
11   end
12   
13   it "should be accessible from example" do
14     @sideeffect.should == 1
15     $global.should == 1
16     @isolated.should == 1
18     @sideeffect += 1
19     @isolated += 1
20   end
22   it "should not have sideffects" do
23     @sideeffect.should == 1
24     $global.should == 2
25     @isolated.should == 1
27     @sideeffect += 1
28     @isolated += 1
29   end
31   after :each do
32     $global += 1
33   end
34   
35   after :all do
36     $global.should == 3
37     $global = 0
38   end
39 end