Sha256: 67df25b324118d0284f862f7b2abb8d37fa0f47fed4622d8eca55c9be1cd6c41

Contents?: true

Size: 652 Bytes

Versions: 82

Compression:

Stored size: 652 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'
$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

82 entries across 82 versions & 12 rubygems

Version Path
typo-5.1 vendor/plugins/rspec/examples/pure/before_and_after_example.rb
typo-5.2 vendor/plugins/rspec/examples/pure/before_and_after_example.rb