Specifying Content Type in rspec

前端 未结 7 1752
终归单人心
终归单人心 2021-01-01 12:57

I\'m trying to build an rspec test that sends JSON (or XML) via POST. However, I can\'t seem to actually get it working:

    json = {.... data ....}.to_json
         


        
7条回答
  •  再見小時候
    2021-01-01 13:48

    I think that you can specify the headers with headers param:

    post '/model1.json', headers: {'Content-type': 'application/json'}
    

    Following the Rspec documentation of how provide JSON data.

提交回复
热议问题