这没有任何意义:
describe SessionsController do
context "We should login to the system and create a session" do
it "should create a session" do
FactoryGirl.create(:user, :user_name => 'Sample-User', :password => '12345678910')
post :create, :user => {:user_name => 'Sample-User', :password => '12345678910'}
assigns(:user).valid?.should == true
end
end
运行时出现以下错误:
Failure/Error: assigns(:user).valid?.should == true
NoMethodError:
undefined method `valid?' for nil:NilClass
我在其他测试中执行此类检查没有任何问题,我在文件顶部有require 'spec_helper'
。
这怎么不是一个有效的方法?