1

I am using Steak and Capybara to do my integration tests. I also would like to test the serialization output (webservices using XML and JSON format) of my models. The problem is that JSON is only available by using a XML HTTP Request. So Capybara's visit method does not work. It also seems that I don't have access to xhr method in my acceptance tests (not sure why, because I require the normal spec_helper.rb in my acceptance_helper.rb).

How do you test web services? Using the xhr method (after requiring it somehow)? A special method with Capybara? Something else?

I also have some custom serialization (beside the normal my_object.to_xml). I guess it is better to do that in the model tests. Would you then still test the web service output of those custom serializations?

4

1 回答 1

0

您始终可以创建一个“代理”控制器,向 Web 服务发出请求并打印结果。显然,它应该只在测试环境中可用。然后您的 Capybara 测试访问代理并测试页面内容。

于 2011-11-11T20:50:27.970 回答