未设置Rails集成测试标头

时间:2014-03-26 21:33:12

标签: ruby-on-rails http-headers integration-testing

@request.headers["Authorization"] = "Token token=#{auth_token}"
post "/verify"

当我puts @request.inspect时,我看到的唯一标题是:

..."action_controller.instance"=>
#<VerificationsController:0x007fc5683ebd38 @_routes=nil, 
@_action_has_layout=true, 
@_headers={"Content-Type"=>"text/html"}...

为什么我的授权标题没有显示?

1 个答案:

答案 0 :(得分:3)

我最终得到了这个工作:

headers = { 'Authorization' => "Token token=\"#{auth_token}\"" } 
json_body = {}
post "api/1.1/cartwheelregister/verify/answers", json_body, headers