In my capybara tests I want to check if certain links are visible or not. Before each test, I login as a foo. Is it possible to access that @foo variable out of the contexts? Would be very handy for the data setup. My source looks like this:
before :each do
@foo = FactoryGirl.create(:foo)
# log in and stuff
end
context "foo wants do leave bar" do
bar = FactoryGirl.create(:bar)
bar.foos << @foo
it "should have link 'leave' if foo is in bar" do
visit #...
end
end
Sadly @foo is reported as nil in the context.