changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/examples/pure/before_and_after_example.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/spec_helper'
2$global = 0
3
4describe "State created in before(:all)" do
5 before :all do
6 @sideeffect = 1
7 $global +=1
8 end
9
10 before :each do
11 @isolated = 1
12 end
13
14 it "should be accessible from example" do
15 @sideeffect.should == 1
16 $global.should == 1
17 @isolated.should == 1
18
19 @sideeffect += 1
20 @isolated += 1
21 end
22
23 it "should not have sideffects" do
24 @sideeffect.should == 1
25 $global.should == 2
26 @isolated.should == 1
27
28 @sideeffect += 1
29 @isolated += 1
30 end
31
32 after :each do
33 $global += 1
34 end
35
36 after :all do
37 $global.should == 3
38 $global = 0
39 end
40end