0

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.

SDD64
  • 706
  • 13
  • 28

1 Answers1

0

I just solved it by myself:

You have to create, access and assign in the it block, not in the context block.

SDD64
  • 706
  • 13
  • 28