Ruby on Rails Rspec 在运行 rake spec:plugins 时迁移数据库

发布于 2024-08-19 00:27:36 字数 278 浏览 2 评论 0原文

我正在尝试测试我通过运行编写的插件:

rake spec:plugins

当我执行此命令时,它似乎会删除我的数据库表(在我的测试数据库中),然后在不加载任何插件的情况下运行迁移,为我提供一个干净的数据库。这通常没问题,但我使用的插件允许我为 MYSQL 设置索引长度限制,因此如果我在没有该插件的情况下运行迁移,则会出现语法错误。这意味着我无法使用 rspec rake 命令测试我的插件。

我找不到该命令的任何文档,有没有办法让它在执行之前不运行任何迁移?

I'm trying to test a plugin that i wrote by running:

rake spec:plugins

When i execute this command it appears that it drops my database tables (in my test DB) and then runs a migration without any plugins loaded to give me a clean database. This would normally be fine, but I am using a plugin that allows me to set index length limits for MYSQL, so if I run a migration without that plugin, then i get a syntax error. This means that i cannot test my plugin with the rspec rake command.

I can't find any documentation for this command, is there a way to get it to not run any migrations before it executes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷夜 2024-08-26 00:27:36

尝试在插件规范中进行设置:

Spec::Runner.configure do |config|
  config.use_transactional_fixtures = false
end

当然,这意味着您必须确保测试数据库处于测试的正确状态,并且在退出时清除所有修改。

Try setting this in your plugin spec:

Spec::Runner.configure do |config|
  config.use_transactional_fixtures = false
end

Of course this means you have to ensure the test DB is in the correct state for your tests, and that you clean up any modifications on exit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文