Search code examples
rubyrspecgrape-api

Cant set custom header params with rspec and Grape


I use Grape api and i need to write a test with custom header

my code:

  it "should accept message" do
    post "/api/v1/my/route", post_data, secret: "ASDFGHJKL"
    last_response.status.should == 201
  end

but the route gets no headers at all, i also tried headers['secret'] = "ASDFGHJKL" and also request.env['secret'] nothing works.

how can i pass headers in rspec to grape route?


Solution

  • Did you try header 'secret', 'ASDFGHJKL'?

    More on the rack-test docs