简体   繁体   English

如何使用curl测试我的Rails控制器创建动作..还是可以使用rspec?

[英]how do I use curl to test my Rails controller create action.. or can I use rspec?

Please bear with me as the Rails guide chooses to not even mention the create action in their API section. 请耐心等待,因为Rails指南选择在其API部分中甚至不提及create操作。 My goal is to build a RESTFUL API from which content can be created. 我的目标是建立一个RESTFUL API,从中可以创建内容。 Here is what the form looks like after $ curl myapp 这是$ 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="&#x2713;" />
    <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>

I want to POST content through curl... or... can I test this somehow through Rspec? 我想通过curl来发布内容...还是...我可以通过Rspec以某种方式对其进行测试吗?

The goal is that I have a RESTFUL API that allows content to be created through HTTP requests and then gives an HTTP response. 我的目标是拥有一个RESTFUL API,该API允许通过HTTP请求创建内容,然后给出HTTP响应。

您可以使用Ruby HTTP Cheat Sheet并直接从Ruby创建各种类型的请求,而无需为此做任何准备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails 3.1 Rspec Rails 2-如何测试此控制器操作? - Rails 3.1 Rspec Rails 2 - How can I test this controller action? 我将如何将此 curl 请求转换为此控制器操作的 RSpec 测试 - How would I turn this curl request into an RSpec test for this controller action Rspec rails:如何测试一次控制器操作是否正确地使用修改后的参数重定向到其自身? - Rspec rails: How do I test if a controller action redirects correctly to itself with modified params once? 如何使用rspec在我的控制器的新操作中测试实例变量的赋值? - How do I test the assignment of an instance variable in the new action of my controller with rspec? Rails:我如何在控制器/动作上使用javascript条件 - Rails: how do I use javascript conditional on controller/action 如何在Rails Controller / Action中使用Ruby改进? - How do I use Ruby refinements inside Rails Controller/Action? 如何在带有rspec的Rails控制器中测试关联? - How do I test association in rails controller with rspec? 使用Rspec,如何在Rails 3.0.11中测试我的控制器的JSON格式? - Using Rspec, how do I test the JSON format of my controller in Rails 3.0.11? 如何创建Rails控制器动作? - How do I create a rails controller action? 如何使用RSpec在我的Rails应用程序中测试JQuery-UI Sortable的控制器交互? - How do I test JQuery-UI Sortable's controller interaction in my Rails app using RSpec?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM