且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过 RSpec 发送自定义标头

更新时间:2022-06-27 07:05:34

好吧,对于人们来说可能为时已晚,但只是为了排队:

well, maybe too late for people but just to be lined up:

it 'should get profile when authorized' do
  user = FactoryGirl.create :user
  request.headers[EMAIL_TOKEN] = user.email
  request.headers[AUTH_TOKEN] = user.authentication_token
  get :profile
  response.should be success
end

只需使用适当的设置调用 request.headers.

just call request.headers with appropriate settings.