English 中文(简体)
铁路使用光谱仪进行电弧试验3.1
原标题:testing logging in function of sorcery using rspec in rails 3.1

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。

最佳回答

页: 1

问题回答

暂无回答




相关问题
Accidentally uninstall rspec

Trying to reinstall RSpec, and I can t seem to re-add its command to my bin folder. Mac-Users-MacBook-Pro:bin macuser$ rspec -bash: /usr/bin/rspec: No such file or directory >> which rspec #&...

Rails 3 RSpec 2 NetBeans integration

NetBeans 6.9 provides a custom Runner class for RSpec to be integrated into the IDE. I m trying to get my Rails 3 applications specs to be correctly displayed inside NetBeans, but RSpec 2 seems no ...

Stubbing Devise in rSpec and Rails3

How would you stub Devise in Rails 3 with rSpec. I have a UsersController and a User model. Both of which are associated with Devise at the moment, I m writing controller specs and I really am having ...

热门标签