我已经覆盖了 Refinery 的会话控制器,甚至还没有修改它,因为我正在尝试为它编写一些规范。
控制器位于 app/controllers/refinery/sessions_controller 中:
module Refinery
class SessionsController < Devise::SessionsController
....
def create
super
rescue ::BCrypt::Errors::InvalidSalt, ::BCrypt::Errors::InvalidHash
flash[:error] = t('password_encryption', :scope => 'refinery.users.forgot')
redirect_to refinery.new_refinery_user_password_path
end
.....
然后,我尝试在 spec/controllers/refinery/sessions_controller_spec.rb 中针对此编写规范:
require 'spec_helper'
describe Refinery::SessionsController do
it "should post ok" do
post :create
response.should be_success
end
end
然而,这给了我一个错误
No route matches {:action=>"create", :controller=>"refinery/sessions"}
这让我感到困惑,因为当我运行 rake 路线时,我得到以下行:
refinery_user_session POST /refinery/users/login(.:format) refinery/sessions#create
有人可以帮忙吗?
Rails 3.2.8,炼油厂 2.0.8