使用泡菜和泡菜?

时间:2011-05-30 20:19:53

标签: cucumber pickle spork

当我使用Pickle时,

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

是什么给出了?

1 个答案:

答案 0 :(得分:1)

所以事实证明,使用spork时features/support/env.rb需要一个额外的配置行才能让Pickle能够在AR模型上拾取,this gist

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

添加此行可修复我的问题。这本身就更像是一个棘手的问题而不是警卫。我会更新我的问题...

相关问题