i have added include Sorcery::TestHelpers::Rails
inside sorcery.rb
my controller spec looks like
describe "success" do
before(:each) do
@user = Factory(:user)
@attr = { :username => @user.username, :password => @user.password }
end
it "should sign the user in" do
post :create, :session => @attr
# controller.current_user.should == @user
controller.should be_logged_in
end
end
我的控制者 looks切希望
class SessionsController < ApplicationController
def create
user = login(params[:username], params[:password], params[:remember_me])
if user
redirect_back_or_to root_url, :notice => "Logged in!"
else
flash.now.alert = "Email or password was invalid"
render :new
end
end
end
i 用户模式已移至我的测试环境,在进行测试时,总是说不gged。