Sha256: f31c2421be1359d6b64811469341f89d316b5839e2abd24ef375d232a6128a7c

Contents?: true

Size: 603 Bytes

Versions: 8

Compression:

Stored size: 603 Bytes

Contents

$global = 0

describe "State created in before(:all)" do
  before :all do
    @sideeffect = 1
    $global +=1
  end

  before :each do
    @isolated = 1
  end
  
  it "should be accessible from example" do
    @sideeffect.should == 1
    $global.should == 1
    @isolated.should == 1

    @sideeffect += 1
    @isolated += 1
  end

  it "should not have sideffects" do
    @sideeffect.should == 1
    $global.should == 2
    @isolated.should == 1

    @sideeffect += 1
    @isolated += 1
  end

  after :each do
    $global += 1
  end
  
  after :all do
    $global.should == 3
    $global = 0
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rspec-0.9.2 examples/before_and_after_example.rb
rspec-0.9.3 examples/before_and_after_example.rb
rspec-0.9.4 examples/before_and_after_example.rb
rspec-1.0.0 examples/before_and_after_example.rb
rspec-1.0.1 examples/before_and_after_example.rb
rspec-1.0.2 examples/before_and_after_example.rb
rspec-1.0.3 examples/before_and_after_example.rb
rspec-1.0.4 examples/before_and_after_example.rb