用泡菜和勺子一起吃吗?

发布于 2024-11-10 12:51:26 字数 714 浏览 0 评论 0 原文

当我使用 Pickle 似乎没有为我加载/github.com/timcharper/spork" rel="nofollow">spork...

如果我正常运行我的黄瓜,该步骤将按预期工作:

➜ bundle exec cucumber

And a product exists with name: "Windex", category: "Household Cleaners", description: "nasty bluish stuff" # features/step_definitions/pickle_steps.rb:4

但是如果我通过 spork 运行它,我会得到一个未定义的步骤:

您可以使用以下代码片段实现未定义步骤的步骤定义:

Given /^a product exists with name: "([^"]*)", category: "([^"]*)", description: "([^"]*)"$/ do |arg1, arg2, arg3|
  pending # express the regexp above with the code you wish you had
end

什么给出了?

Pickle doesn't seem to be loading for me when I'm using spork...

If I run my cucumber normally, the step works as expected:

➜ bundle exec cucumber

And a product exists with name: "Windex", category: "Household Cleaners", description: "nasty bluish stuff" # features/step_definitions/pickle_steps.rb:4

But if I run it through spork, I get an undefined step:

You can implement step definitions for undefined steps with these snippets:

Given /^a product exists with name: "([^"]*)", category: "([^"]*)", description: "([^"]*)"$/ do |arg1, arg2, arg3|
  pending # express the regexp above with the code you wish you had
end

What gives?

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

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

发布评论

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

评论(1

纸伞微斜 2024-11-17 12:51:26

因此,事实证明,在使用 spork 时,features/support/env.rb 需要额外的配置行,以便 Pickle 能够在 AR 模型上拾取,例如 这个要点

features/support/env.rb

Spork.prefork do
  ENV["RAILS_ENV"] ||= "test"
  require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')

  # So that Pickle's AR adapter properly picks up the application's models.
  Dir["#{Rails.root}/app/models/*.rb"].each { |f| load f }

  # ...
end

添加这一行可以解决我的问题。本质上,这更像是一个 Spork 问题,而不是 Guard 问题。我会更新我的问题...

So it turns out there is an extra config line necessary for features/support/env.rb when using spork in order to have Pickle be able to pickup on AR models, a la this gist:

In features/support/env.rb

Spork.prefork do
  ENV["RAILS_ENV"] ||= "test"
  require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')

  # So that Pickle's AR adapter properly picks up the application's models.
  Dir["#{Rails.root}/app/models/*.rb"].each { |f| load f }

  # ...
end

Adding in this line fixes my problem. This is more of a spork issue than guard, per se. I'll update my question...

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