Specifying Content Type in rspec

前端 未结 7 1707
终归单人心
终归单人心 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:57

    In Rails 3, you can skip the header and @request.env stuff and just add a format parameter to your post call, e.g.:

    post :create, format: :json, param: 'Value of Param'
    
    0 讨论(0)
提交回复
热议问题