我正在尝试使用rails 3设置工厂女孩,但是当我rake cucumber
时我收到此错误:
james@james-laptop:~/rails-projs/simple-beach-63$ rake cucumber:wip (in /home/james/rails-projs/simple-beach-63) bundle exec /usr/bin/ruby1.8 -I "/usr/lib/ruby/gems/1.8/gems/cucumber-0.9.4/lib:lib"
“/ usr / lib中/红宝石/宝石/ 1.8 /宝石/黄瓜-0.9.4 / bin中/黄瓜” --profile wip 使用wip配置文件...... 未初始化的常量Factory(NameError) /usr/lib/ruby/gems/1.8/gems/rspec-expectations-2.1.0/lib/rspec/expectations/backward_compatibility.rb:6:in
const_missing' /usr/lib/ruby/gems/1.8/gems/factory_girl-1.3.3/lib/factory_girl/step_definitions.rb:25 /home/james/rails-projs/simple-beach-63/features/support/env.rb:8:in
需要” /home/james/rails-projs/simple-beach-63/features/support/env.rb:8
当你得到一秒时,你可以拉一下吗?
我在Gemfile中有这个:
gem 'factory_girl_rails'
gem 'factory_girl'
我在feature / support / env.rb
中有这个require "factory_girl/step_definitions"
require "factory_girl"
require File.dirname(__FILE__) + "/factories"
然后我在features / support / factories.rb
中定义了一个工厂我很感激任何帮助
答案 0 :(得分:8)
您应该只需要这些步骤。
的Gemfile:
group :development, :test do
gem "rspec-rails"
end
group :test do
gem "cucumber-rails"
gem "factory_girl_rails"
end
特征/支持/ factory_girl.rb:
require 'factory_girl/step_definitions'
规格/ factories.rb:
# your Factory definitions.
答案 1 :(得分:3)
我已按照您的步骤操作,但我仍然无法使用工厂女孩步骤定义。
当我尝试:
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)
You can implement step definitions for undefined steps with these snippets:
Given /^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
关于缺少什么的任何想法?
答案 2 :(得分:0)
这里的问题是你没有正确地调用你的桌子。从您的要素文件中调用该表的行应如下所示:
And the following user with <login> and <email> <password> and <confirmation> exists
您的步骤定义应如下所示:
And /^The following user with ([A-za-z0-9\.@:]+) and ([A-za-z0-9\.@:]+) ([A-za-z0-9\.@:]+) and ([A-za-z0-9\.@:]+) exists$/ do |login, email, password, confirmation|