我正在嘗試使用黃瓜和工廠女孩。下面的幾行:在Cucumber特性中使用Factory Girl步驟定義(Rails 3)
Given I am not logged in
And the following user exists:
| login | email | password | confirmation |
| user50 | [email protected] | secret50 | secret 50 |
....
引發以下錯誤:
Undefined step: "the following user exists:" (Cucumber::Undefined exception)
/home/user/RubymineProjects/project/features/sign_in.feature:9:in `And the following user exists:
You can implement step definitions for undefined steps with these snippets:
And /^the following user exists:$/ do |table|
# table is a Cucumber::Ast::Table
pending # express the regexp above with the code you wish you had
end
'
我已經安裝了factory_girl_rails(甚至RubyMine的代碼完成功能與工廠女孩步的作品...)
#Gemfile
group :test do
gem "cucumber-rails", ">= 0.3.2"
gem "factory_girl_rails"
end
#features/support/env.rb
require 'factory_girl'
require 'factory_girl/step_definitions'
任何想法?謝謝
更新:感謝@ sj26和@twmills我意識到我忘了用Factory Girl創建一個:用戶工廠。一旦我創建它,一切運作良好。
你有users.rb的工廠文件? – twmills 2011-05-18 15:51:50