rspec/rspec-rails — Issue #459: View variable scope
Author: jackquack
Created: 2011-11-01 20:10:36+00:00
State: open

I'm having trouble with my variables not being in scope when I'm running view tests.

It seems that when I run a helper method from one of my views when I'm testing that view, the 'current_user' variable is not within the scope of that helper method.
This is causing my helper to complain about 'undefined variable or method current_user'. I've tried a few things to set the 'current_user' variable in my 'before(:each)' block, but it seems that no matter what I try, the helper method still cannot use 'current_user'.

The current_user IS visible as a variable within the view itself when I run tests, and IS visible to the helper when NOT testing. The helper method does NOT receive the variable 'current_user' as a param. I'm using Devise and I am logging a user in before I run the test.
Should I maybe be stubbing the helper method? THANKS!