Set request headers for Rspec and Rack::Test in Ruby on Rails Set request headers for Rspec and Rack::Test in Ruby on Rails json json

Set request headers for Rspec and Rack::Test in Ruby on Rails


I think what you are doing should work. Also, you can set a header withheader('name', 'value').

Anyways, you should check

post '/api/v1/auth/sign_in', email: user.email, password: user.password, format: :json

The user.password should be hashed, so if you send it like that you won't be logged in.