我有Project
控制器和 rspec 文件。我current_user
以这种方式使用助手:
# projects_controller_spec.rb
describe "user signed in" do
before(:each) { sign_in @user }
after(:each) { sign_out @user}
describe "GET index" do
it "assigns all projects as @projects" do
project = FactoryGirl.create(:project, :user => current_user)
get :index, {}, valid_session
assigns(:projects).should eq([project])
end
end
...
end
帮手sign_in
,sign_out
似乎工作正常,但我有一个错误current_user
:
undefined local variable or method `current_user'
可能是什么问题,如何解决?