Customize factory girl with cucumber and rails 3

I am trying to set the factory girl setting with rails 3, but I get this error when I 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 / Library / ruby ​​/ stones / 1,8 / gems / cucumber 0.9.4 / bin / cucumber" --profile wip Using a 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:inrequired "/ home / james / rails -projs / simple-beach-63 / features / support / env. rb: 8

Can you pull and take a look when you get a second?

I have this in the gemfile:

gem 'factory_girl_rails'
gem 'factory_girl'

I have it in the function /support/env.rb

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

and then I define the factory in the /support/factories.rb functions

I would be grateful for any help

+3
3

.

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.
+8

,

, factory.

:

  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

, ?

+3

The problem is that you are not calling your table correctly. The line calling the table from your function file should look like this:

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

Your step definition should look like this:

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|
0
source

Source: https://habr.com/ru/post/1787051/


All Articles