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
dchelimsky-rspec-1.1.10 examples/pure/before_and_after_example.rb
dchelimsky-rspec-1.1.11.1 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.11.2 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.11.3 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.11.4 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.11.5 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.11.6 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.11.7 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.11 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.12 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.1 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.13 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.2 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.3 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.4 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.5 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.6 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.7 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.8 examples/passing/before_and_after_example.rb
dchelimsky-rspec-1.1.99.9 examples/passing/before_and_after_example.rb