Sending custom headers through RSpec

前端 未结 3 1000
一整个雨季
一整个雨季 2021-02-04 02:28

Given my API consumers are required to send a customer HTTP header like this:

# curl -H \'X-SomeHeader: 123\' http://127.0.0.1:3000/api/api_call.json
         


        
3条回答
  •  情歌与酒
    2021-02-04 02:47

    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
    

    just call request.headers with appropriate settings.

提交回复
热议问题