0
我在這個測試中得到undefinded local variable or method user
。任何人幫助?Rspec'範圍之前的範圍
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