如何集成测试两个 Rails 应用程序 [英] How to integration test two Rails apps

查看:41
本文介绍了如何集成测试两个 Rails 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个独立的 Ruby on Rails 应用,一个接受上传的文件,另一个从另一个应用收到的上传中生成文件.

We have two separate Ruby on Rails apps, one that accepts uploaded files, the other that produces files from the uploads the other app received.

我们正在尝试将端到端的黑盒回归和集成测试放在一起,以证明当您将某个文件上传到第一个应用时,您可以指望从另一个应用中获取某个文件.

We're trying to put together end-to-end blackbox regression and integration tests that demonstrate that when you upload a certain file to the first app, you can count on getting a certain file out of the other app.

问题是如何编写脚本,以便使用种子值重置两个独立的数据库,启动两个服务器并且 Capybara 访问两个独立的网站".

The question is how to script this, so that the two separate databases are reset with seeded values, the two servers are fired up and Capybara visits the two separate "web sites."

到目前为止,在构建和测试每个应用程序时,我们都依赖 Rails 魔法使事情正常运行",因此处理单独的数据库、单独的服务器端口和其他未知问题看起来像是一个绊脚石.

So far in building and testing each app we have relied on the Rails magic that makes things "just work," so dealing with separate databases, separate server ports and other unknown wrinkles is looking like a stumbling block.

有人写过这种测试的最佳实践吗?任何有关如何自动化此类集成测试的示例?

Has anyone written up best practices for this kind of testing? Any examples of how to automate this kind of integration testing?

推荐答案

您可以使用 Heroku 将这两个应用程序联机.然后使用来自sauselabs.com 的sauce_ruby gem 作为连接器,让rspec 和capybara 再次运行测试应用程序.运行 heroku run rake db:reset 以在测试之前重新播种(使用seed.rb)数据(您可以编写脚本).酱红宝石

You can put the both apps online with Heroku. Then use sauce_ruby gem from saucelabs.com as a connector to get rspec and capybara to run tests agains apps. Run heroku run rake db:reset to reseed (with seed.rb) the data before the tests(you can script this). sauce ruby

这篇关于如何集成测试两个 Rails 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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