Skip to content

Instantly share code, notes, and snippets.

@sleexyz
Created July 7, 2017 04:54
Show Gist options
  • Save sleexyz/4de8cf8c93a1b74f7c372e0d303cca70 to your computer and use it in GitHub Desktop.
Save sleexyz/4de8cf8c93a1b74f7c372e0d303cca70 to your computer and use it in GitHub Desktop.
rspec test isolation
# 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