我undefinded local variable or method user
在这个测试中得到了一个。有人帮忙吗?
context "[user IS signed in]" do
before do
user = Fabricate(:user)
league = Fabricate(:league)
event = Fabricate(:event, league: league)
@request.env["devise.mapping"] = Devise.mappings[:user]
sign_in user
ApplicationController.any_instance.stub(:primary_leagues).and_return([league])
end
it "[creates a pick for a user]" do
post 'create', {:pick => {user_id: user.id, event_id: event.id, league_id: league.id, points_pick: "home"}}
Pick.all.size.should eq(1)
end