无法在 rspec 中获取响应标头?

geo*_*rtz 5 rspec ruby-on-rails

在我的控制器中,我有以下 before_action...

def cors_set_headers
    headers['Access-Control-Allow-Origin'] = '*'
    headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
    headers['Access-Control-Request-Method'] = '*'
    headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
Run Code Online (Sandbox Code Playgroud)

我正在尝试编写一个测试以确保使用以下代码设置这些标头...

describe 'cors headers action ' do
  it 'sets the proper headers' do
    get :jobs, format: :json
    p response.headers
    expect(response.headers['Access-Control-Allow-Origin']).to eq('*')
    expect(response.headers['Access-Control-Allow-Methods']).to eq('POST, PUT, DELETE, GET, OPTIONS')
    expect(response.headers['Access-Control-Request-Method']).to eq('*')
    expect(response.headers['Access-Control-Allow-Headers']).to eq('Origin, X-Requested-With, Content-Type, Accept, Authorization')
  end
end
Run Code Online (Sandbox Code Playgroud)

当我做 p response.headers 时,唯一返回的标题是 - {"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content- Type-Options"=>"nosniff", "Content-Type"=>"text/html; charset=utf-8"}

这在我的应用程序中运行良好,但不适用于测试。那么,知道可能是什么问题吗?谢谢。