![](/img/trans.png)
[英]Rails 3.1 Rspec Rails 2 - How can I test this controller action?
[英]how do I use curl to test my Rails controller create action.. or can I use rspec?
請耐心等待,因為Rails指南選擇在其API部分中甚至不提及create操作。 我的目標是建立一個RESTFUL API,從中可以創建內容。 這是$ curl myapp
之后的形式
<form class="new_blog" id="new_blog" action="/blog" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓" />
<label for="blog_input">Input a String</label>
<textarea class="input-field" name="blog[input]" id="blog_input">
</textarea>
<input type="submit" name="commit" value="Create Blog" />
</form>
我想通過curl來發布內容...還是...我可以通過Rspec以某種方式對其進行測試嗎?
我的目標是擁有一個RESTFUL API,該API允許通過HTTP請求創建內容,然后給出HTTP響應。
您可以使用Ruby HTTP Cheat Sheet並直接從Ruby創建各種類型的請求,而無需為此做任何准備。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.