我想在控制器规范中设置一个 auth_token 值。我有以下内容:
describe ApiEditController do
before do
session[:auth_token]='abc123' # doesn't work
end
it 'should edit item' do
# lets create a location
#....
end
end
但是当我检查会话时,我没有提到 auth_token:
{"format"=>"json", "flash"=>#<ActionDispatch::Flash::FlashHash:0x007fe592813cb8 @used=#<Set: {}>, @closed=false, @flashes={}, @now=nil>}
如果我通过网络界面做同样的事情,我会得到:
{"session_id"=>"f16e0a6a0b4942bcad2fd191b49c9078", "the_last_url"=>"http://localhost:3000/arc/menus/12/edit", "_csrf_token"=>"MuQfgciiZjVpaAYiwrbDHGvcyChf6m0ex2QV8GHzOIs=", "auth_token"=>"vfieGDt_iEmSQjllLL5N6g"}
为什么我没有在我的规范请求中获得 auth_token 值?它是否以不同的方式访问 Rack::Middleware?
谢谢