ruby-on-rails-3 – 在Cucumber功能中使用Factory Girl步骤定义(
我正在尝试使用Cucumber和Factory Girl.以下行:
Given I am not logged in And the following user exists: | login | email | password | confirmation | | user50 | user50@mydomain.com | 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的代码完成功能也适用于Factory Girl步骤……) #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的用户工厂.一旦我创建它,一切都运作良好. 解决方法
对于那些现在尝试使用FactoryGirl助手的人:
从FactoryGirl 3.5.0开始,不推荐使用这些步骤助手,并在4.0.0:http://robots.thoughtbot.com/post/25650434584/writing-better-cucumber-scenarios-or-why-were中将其删除
因此,如果您想在Cucumber中使用FactoryGirl,您应该在自己的步骤定义中使用它. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |