Created
July 9, 2015 17:59
-
-
Save oafridi/f3f9b24bc71150ce3ca2 to your computer and use it in GitHub Desktop.
before vs before each vs before all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
$count = 0 | |
$count_each = 0 | |
$count_all = 0 | |
shared_examples_for "before :each" do | |
it { should == 1 } | |
it { should == 2 } | |
end | |
describe "before" do | |
before do | |
$count += 1 | |
end | |
subject { $count } | |
it_should_behave_like "before :each" | |
end | |
describe "before :each" do | |
before :each do | |
$count_each += 1 | |
end | |
subject { $count_each } | |
it_should_behave_like "before :each" | |
end | |
describe "before :all" do | |
before :all do | |
$count_all += 1 | |
end | |
subject { $count_all } | |
it { should == 1 } | |
it { should == 1 } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment