Ruby on Rails中的RESTful POST的功能测试 [英] Functional testing of a RESTful POST in Ruby on Rails

查看:65
本文介绍了Ruby on Rails中的RESTful POST的功能测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Ruby on Rails应用程序中正在使用的RESTful Web服务编写功能测试.

I'd like to write a functional test of a RESTful web service I'm working on in a Ruby on Rails app.

测试是对POST请求的,其中请求的主体是纯XML文档而不是表单.关于如何执行此操作的任何指示?我遇到的问题是如何在对post方法的调用中指定主体XML.

The test is of a POST request where the body of the request is a plain XML doc and not a form. Any pointers on how to do this? The problem I'm encountering is how to specify the body XML in the call to the post method.

推荐答案

以下内容对我有用:

@request.env['RAW_POST_DATA'] = MY_XML_STRING
post :create   

这篇关于Ruby on Rails中的RESTful POST的功能测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆