2014-07-17 38 views
0

這個測試的等效cURL請求是什麼?等效捲曲請求

test "create user" do 
     user = { 
      user: { 
       username: "fasfas", 
       password: "fasfas", 
       password_confirmation: "fasfas", 
       email: "[email protected]" 
      } 
     } 
     post "/users", user, {"Accept" => "application/json"} 
     assert_equal response.status, 201 
    end 

我試圖像

curl http://someurl.com/users -d "username=...&password=..." 

等,但由於控制器需要user PARAM它不工作。

回答

1

試試這個

curl -X POST -d "user[username]=fasfas&user[password]=fasfas&user[password_confirmation]=fasfas&user[email][email protected]" http://someurl.com/users 
+0

它的工作!順便說一句,我讀了其他問題,如果你使用'-d'選項,你不需要指定POST方法。無論如何,感謝fella! – tehAnswer