2011-01-22 2 views
3

레일,하지만 난 rake cucumber 때이 오류 받고 있어요 :는 오이 공장 소녀를 설정하고 내가 레일 3 공장 소녀 설정을 얻으려고 3

[email protected]:~/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/ruby/gems/1.8/gems/cucumber-0.9.4/bin/cucumber" --profile wip Using the wip profile... uninitialized constant 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 require' /home/james/rails-projs/simple-beach-63/features/support/env.rb:8

당신이 끌어와 좀 걸릴 수 있습니다 잠깐만 요?

나는 Gemfile이 있습니다

gem 'factory_girl_rails' 
gem 'factory_girl' 

내가 기능/지원/env.rb에

require "factory_girl/step_definitions" 
require "factory_girl" 
require File.dirname(__FILE__) + "/factories" 

을이 있고 나는이 기능에 공장을/지원/factories.rb을 정의

어떤 도움을 주시면 감사하겠습니다.

+0

당신이 대신 factory_girl_rails 보석을 어떻게 사용하면 어떻게됩니까 :

And the following user with <login> and <email> <password> and <confirmation> exists 

귀하의 단계 정의는 같이해야합니까? – monocle

답변

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. 
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) 

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 

어떤 아이디어?

+0

단계 정의가 공장에서 생성되므로 features/support/factory_girl.rb에서'factory_girl_rails '를 먼저 요구해야합니다. – RobinGower

0

여기서 문제는 테이블을 올바르게 호출하지 않는다는 것입니다. 당신의 기능 파일에서 테이블을 호출하는 줄은 다음과 같아야합니다

And /^The following user with ([A-za-z0-9\[email protected]:]+) and ([A-za-z0-9\[email protected]:]+) ([A-za-z0-9\[email protected]:]+) and ([A-za-z0-9\[email protected]:]+) exists$/ do |login, email, password, confirmation| 
관련 문제