Rspec 在RSspec控制器规范中设置会话[:auth_令牌]

Rspec 在RSspec控制器规范中设置会话[:auth_令牌],rspec,ruby-on-rails-3.2,Rspec,Ruby On Rails 3.2,我想在控制器规范中设置auth_令牌值。我有以下内容: 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_令牌: {"format"=>"json",

我想在控制器规范中设置auth_令牌值。我有以下内容:

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_令牌:

{"format"=>"json", "flash"=>#<ActionDispatch::Flash::FlashHash:0x007fe592813cb8 @used=#<Set: {}>, @closed=false, @flashes={}, @now=nil>}
为什么我不能在我的规范请求中获得auth_令牌值?是否以不同方式访问Rack::Middleware


thx

使用
request.session
而不仅仅是
session

它看起来像
request.session['auth_token']='abc123'
完成了,如果您编辑答案,我会接受。
{"session_id"=>"f16e0a6a0b4942bcad2fd191b49c9078", "the_last_url"=>"http://localhost:3000/arc/menus/12/edit", "_csrf_token"=>"MuQfgciiZjVpaAYiwrbDHGvcyChf6m0ex2QV8GHzOIs=", "auth_token"=>"vfieGDt_iEmSQjllLL5N6g"}