How to post JSON data in rails 3 functional test

前端 未结 7 1821
礼貌的吻别
礼貌的吻别 2021-02-04 06:55

I plan to use JSON data in both request and response in my project and having some problems in testing.

After searching for a while, I find the following code which uses

7条回答
  •  再見小時候
    2021-02-04 07:30

    I found that this does exactly what I want – post JSON to a controller's action.

    post :create, {:format => 'json', :user => { :email => "test@test.com", :password => "foobar"}}
    

提交回复
热议问题