使用 Spork 时如何加载机械师的蓝图?

发布于 2024-10-15 05:42:24 字数 775 浏览 7 评论 0原文

使用 Spork 时如何加载 Machinist 的蓝图?

宝石:

  • mongoid (2.0.0.rc.6)
  • capybara (0.4.1.1)
  • Steak (1.1.0)
  • spork (0.9.0.rc2)
  • rspec (2.4.0)
  • machinist (2.0.0.beta2)

我收到此错误在每个验收测试中:

Machinist::NoBlueprintError:
   No master blueprint defined for class School

所有测试都失败,因为它找不到任何蓝图。我在 V2 上遇到了一些错误(我仍然得到了一些 No master blueprint..),但我也得到了另一个错误:

Professor Create a new professor
 Failure/Error: click_link("Profesores")
 RangeError:
   0x000000821461e4 is recycled object

我在这个测试环境中得到了 config.cache_classes = false 。

两个spec_helper版本:

https://gist.github.com/801814

How do you load Machinist's blueprints when using Spork?

Gems:

  • mongoid (2.0.0.rc.6)
  • capybara (0.4.1.1)
  • steak (1.1.0)
  • spork (0.9.0.rc2)
  • rspec (2.4.0)
  • machinist (2.0.0.beta2)

I get this error in every acceptance test:

Machinist::NoBlueprintError:
   No master blueprint defined for class School

All test fail, because it doesn't find any blueprint. I some of these errors on V2(I still get a couple of No master blueprint..), but I get another error too:

Professor Create a new professor
 Failure/Error: click_link("Profesores")
 RangeError:
   0x000000821461e4 is recycled object

I got config.cache_classes = false in test environment for this one.

Both spec_helper versions:

https://gist.github.com/801814

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

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

发布评论

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

评论(1

荭秂 2024-10-22 05:42:24

只是为了排除明显的情况,您是否在 application.rb 文件中包含了类似的内容:

config.generators do |g|
  g.fixture_replacement :machinist      
end

另外,您是否在以下位置设置了蓝图文件:

features/support/blueprints.rb for cucumber   
spec/support/blueprints.rb for rspec

并确保您已将: 包含

require 'machinist/active_record'

在蓝图的顶部。

另外,当您启动并运行它时,还要注意一下。 Machinist 缓存了大量对象以使其运行速度更快,但当不断尝试清除数据库时,它有时可能会让您出错。如果遇到问题,您可以通过将其添加到 config/environments/test.rb 文件来关闭 Machinists 缓存:

Machinist.configure do |config|
  config.cache_objects = false
end

Just to rule out the obvious have you included something like this in your application.rb file:

config.generators do |g|
  g.fixture_replacement :machinist      
end

Also have you set up your blueprints files in:

features/support/blueprints.rb for cucumber   
spec/support/blueprints.rb for rspec

and made sure you've included:

require 'machinist/active_record'

in the top of your blueprints.

Also just on another note for when you get it up and running. Machinist caches a lot of objects to make it run faster, but it may occasionally trip you up when constantly trying to clear out the database. If you run into problems you can turn off Machinists caching by adding this to your config/environments/test.rb file:

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