I'd like to test with RSpec a controller receiving this kind of request:
curl -X POST \
--data "{\"same_key\": \"value_in_body\"}" \
--header "same_key: value_in_header" \
"http://localhost:5000/articles/?same_key=value_in_querystring"
having:
same_key
in the bodysame_key
in the headersame_key
in the querystring
and where:
request.request_parameters["same_key"]
:"value_in_body"
request.headers["same_key"]
:"value_in_header"
request.query_parameters["same_key"]
:"value_in_querystring"
I wrote this test:
RSpec.describe ArticlesController, type: :controller do
describe '#create' do
it 'creates an article' do
post :post,
as: :json,
params: { same_key: 'value_in_body' },
headers: { same_key: 'value_in_header' }
expect(response).to have_http_status(:created)
end
end
end
So far, it would be good for the body param and the header param.
But how should we do to also send the querystring param?