Created
July 7, 2017 04:54
-
-
Save sleexyz/4de8cf8c93a1b74f7c372e0d303cca70 to your computer and use it in GitHub Desktop.
rspec test isolation
This file contains hidden or 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
# 1. tests should not leak to sibling describe blocks | |
describe "asdf" do | |
describe "inner 1" do | |
it "works" do | |
expect(defined? @foo).to eql nil | |
end | |
end | |
it "(mutation)" do | |
@foo = true | |
end | |
end | |
# 2. tests should not leak to sibling describe blocks when a higher beforeEach exists | |
describe "asdf" do | |
before(:each) do | |
@foo = true | |
end | |
describe "inner 1" do | |
describe "superinner 1" do | |
it "works" do | |
expect(@foo).to be true | |
end | |
end | |
it "setting foo" do | |
@foo = false | |
end | |
end | |
end | |
# 3. tests should not leak to sibling describe blocks when a sibling beforeEach exists | |
describe "asdf" do | |
before(:each) do | |
@foo = true | |
end | |
describe "inner 1" do | |
it "works" do | |
expect(@foo).to be true | |
end | |
end | |
it "setting foo" do | |
@foo = false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment