RoR:使用 mysql 和 sqlite 高效测试项目
我想不断测试和基准测试在 mysql 和 sqlite 上运行的 RoR 应用程序,并且我正在寻找简化这一过程的技术。理想情况下,我想要一些东西:
- 使用 mysql 和 sqlite 版本的应用程序进行同步自动测试/rspec 测试,这样我就可以立即知道我是否损坏了某些东西
- 用于编写特定于数据库的代码的可靠构造,因为我需要偶尔闯入“ActiveRecord::Base.connection.select_all()”。
后者看似容易,前者看似困难。我考虑过拥有两个独立的源代码树,每个都有自己的特定于数据库的配置文件(例如 Gemfile、config/database.yml),并使用文件系统链接来共享所有常见文件,但这可能会让 git 感到害怕和困惑。
更简洁的方法是使用命令行切换到 Rails,以指定 Rails 启动时使用哪种配置。虽然这很好,但我不认为存在这样的命令行开关
其他人如何处理这个?
I'd like to continually test and benchmark my RoR app running over both mysql and sqlite, and I'm looking for techniques to simplify that. Ideally, I'd like a few things:
- simultaneous autotest / rspec testing with mysql and sqlite versions of the app so I'll know right away if I've broken something
- a dependable construct for writing db-specific code, since I need to break into `ActiveRecord::Base.connection.select_all()` once in a while.
The latter seems easy, the former seems difficult. I've considered having two separate source trees, each with its own db-specific config files (e.g. Gemfile, config/database.yml) and using filesystem links to share all common files, but that might frighten and confuse git.
A cleaner approach would be a command line switch to rails to say which configuration to use as rails starts up. Though it would be nice, I don't think such a command line switch exists
How do other people handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我是您,我会做两件事:
If I were you, I would do two things:
好的,只需进行一些调整,就有一种简单的方法可以在多个数据库中的任何一个下运行您的应用程序和测试。我在以下位置描述了该技术:
RoR:如何测试我的应用程序针对多个数据库?
它对我来说效果很好——其他人可能会发现它有用。
Okay, with just a couple of tweaks, there's a simple way to run your app and tests under any one of several databases. I describe the technique in:
RoR: how do I test my app against multiple databases?
It works well for me -- someone else might find it useful.