Rails:测试生产 [英] Rails : Testing production

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

问题描述

我们正在开发一个 Rails 3 项目并使用 Capybara/RSpec 进行测试.问题是登台和生产环境有些不同.有时,测试运行良好,暂存没有问题,但在生产中会中断.

We're working on a Rails 3 project and testing using Capybara/RSpec. The problem is that the staging and production environment differ somewhat. Sometimes, the tests will run fine and there will be no problem on staging, but will break in production.

一个例子是我们添加了一个使用 Rack::File 发送文件的中间件.该应用程序发送了在 Apache 下工作的标头X-Sendfile",但 Nginx 需要X-Accel-Redirect".

An example is when we added a middleware that uses Rack::File to send files. The application sent the header 'X-Sendfile' which works under Apache but Nginx expects 'X-Accel-Redirect'.

我正在寻找在我们投入生产时运行一系列测试的最佳方法.有没有人做过这个?理想情况下,不应在生产服务器本身上运行测试.

I'm looking for the best way to run a battery of tests when we push to production. Has anyone done this? Ideally the tests should not be run on the production server itself.

这些测试将基本上涵盖我们产品的核心功能,并且与我们当前正在运行的测试有所不同.

The tests would basically cover the core features of our product and would be different from the tests we are currently running.

非常感谢

推荐答案

我最终做的是在具有数据库只读访问权限的 production_test 环境中进行另一组 RSpec 测试.我使用 capybara-webkit 驱动程序,每个测试都从访问该测试的完整 URL 开始.

What I ended up doing is have another set of RSpec test in a production_test environment that has read-only access to the database. I use the capybara-webkit driver and each test starts by visiting the complete URL for that test.

这篇关于Rails:测试生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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