I feel like I’m missing something pretty basic, but I can’t seem to figure it out, either.
When doing the following spec:
require 'spec_helper'
describe "/mymodel/show.html.erb" do
before(:each) do
@mymodel = Factory(:mymodel)
@user = Factory(:user)
assign(:web_tip, @mymodel)
assign(:current_user, @user)
end
it "renders attributes in <p>" do
render
rendered.should have_text(/somevalue/)
end
end
I get an error that the local variable current_user is undefined (the view’s layout wants to call it to show the current login status).
I’m on Rails 3, Rspec 2.6.4, and thought I was following the current docs correctly.
Well, I never figured out how to get authlogic to work with this, so I monkeypatched a current_user method on the tests themselves to get it to work.
Worked, though I’d still award an “answer” if someone can help me to di the right way.