ruby on rails - Generate request with raw post json, headers and additional parameters -
what need:
- send post request in rspec test
- with raw json data
- a specific header
- beside need 2 more params in action generated uri routing.
any suggestions?
i know can use
post :action, 'raw data', 'content_type' => 'application/json', 'custom-header' => 'value' but how add 2 params?
update:
i can send request need curl way:
curl -v -h "content-type: application/json" -h 'custom-header: value' -x post -d @data.txt http://url.of.my.app here @data.txt file raw data. , parameters i've mentioned in last bullet taken url
you can pass custom things in third parameter.
post :action, { your: json }, { content_type: 'application/json', custom_header: 'my_header } http://api.rubyonrails.org/classes/actiondispatch/integration/requesthelpers.html#method-i-get
Comments
Post a Comment