如何在 Rails 中正确设置事务装置?

发布于 2024-09-09 09:59:01 字数 821 浏览 6 评论 0原文

我昨天刚刚开始一个新项目,遇到了很多非常奇怪的事务固定问题。听起来这是 Rails 的一个问题,所以我希望 StackOverflow 能够提供帮助。这是概要。

  • 同事可以很好地运行测试。他们运行的是 Mac OS X;我正在运行 Ubuntu。

  • use_transactional_fixturestrue 时,许多测试都会失败,并显示 can't find [record] with ID=[some-id]。我的同事在此模式下运行,但没有遇到任何问题。

  • 如果我将 use_transactional_fixtures 设置为 false,几乎所有之前失败的测试都会再次通过。我的同事没有看到任何差异,只是测试运行速度稍慢,因为不再使用事务。

  • 当测试单独运行时(rake spec SPEC=spec/some-specific-spec.rb)且固定装置为false,有在测试 #1,234 中失败,并且仅测试 #1,234。

  • 当测试全部一起rake规范)运行且固定装置为false时,测试#3,456中出现失败,并且仅测试 #3,456。

  • 这两个测试没有任何明显的相关性。有很多测试(超过 5,000 个),因此可能发生巧合似乎并不令人意外。

您会从这种情况中得出什么推论,以及您将如何解决它?

I just started a new project yesterday and I'm having a lot of very strange transactional fixture problems. It sounds like this is something of an issue with Rails, so I'm hoping StackOverflow can help. Here's the rundown.

  • Coworkers can run tests fine. They are running Mac OS X; I'm running Ubuntu.

  • When use_transactional_fixtures is true, lots of tests fail with can't find [record] with ID=[some-id]. My coworkers run in this mode, but experience no problems.

  • If I set use_transactional_fixtures to false, almost all of the previously failing tests pass again. My coworkers don't see a difference, except that the tests run moderately slower since transactions aren't being used anymore.

  • When tests are run individually (rake spec SPEC=spec/some-specific-spec.rb) with fixtures on false, there is a failure in test #1,234, and only test #1,234.

  • When tests are run all together (rake spec) with fixtures on false, there is a failure in test #3,456, and only test #3,456.

  • These two tests are not related in any apparent way. There are a lot of tests (over 5,000), so it doesn't seem terribly surprising that there might be a coincidence happening.

What inferences would you draw from this situation, and how would you go about fixing it?

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

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

发布评论

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

评论(1

紧拥背影 2024-09-16 09:59:01

看起来最新的 Rails-rspec2 有问题:
http://github.com/rspec/rspec-rails/issues/issue/ 58

Looks like there is an issue with latest rails-rspec2:
http://github.com/rspec/rspec-rails/issues/issue/58

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