Created
March 5, 2022 17:07
-
-
Save adamcameron/641efac5061bf59a95a5f91419f3fc2c to your computer and use it in GitHub Desktop.
Demonstrates the order in which lifecycle event handlers run in rspec
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
describe "Lifecycle function tests" do | |
test_array = [] | |
before(:all) do | |
test_array.push "main block before :all handler" | |
end | |
before(:each) do # or just before with no param | |
test_array.push "main block before :each handler" | |
end | |
describe "first block" do | |
before(:all) do | |
test_array.push "first block before :all handler" | |
end | |
before(:each) do # or just before with no param | |
test_array.push "first block before :each handler" | |
end | |
it "is a test" do | |
test_array.push "first block a test" | |
expect(test_array).to eq [ | |
"main block before :all handler", | |
"first block before :all handler", | |
"main block before :each handler", | |
"first block before :each handler", | |
"first block a test" | |
] | |
end | |
it "is another test" do | |
test_array.push "first block another test" | |
expect(test_array).to eq [ | |
"main block before :all handler", | |
"first block before :all handler", | |
"main block before :each handler", | |
"first block before :each handler", | |
"first block a test", | |
"main block before :each handler", | |
"first block before :each handler", | |
"first block another test" | |
] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment