0

当我使用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

是什么赋予了?

4

1 回答 1

1

所以事实证明,features/support/env.rb在使用 spork 时需要额外的配置行,以使 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 问题而不是警卫问题。我会更新我的问题...

于 2011-05-30T22:14:13.363 回答