undefined method `Factory' for #<Object:0x007fd5a0740ef0> (NoMethodError)
ricardopacheco opened this issue · 2 comments
ricardopacheco commented
FactoryGirl.define do
factory :user do
name "Jane Doe"
sequence(:email) { |n| "jane#{n}@example.org" }
password "password"
password_confirmation "password"
end
preload do
factory(:jane) { Factory(:user) }
end
end
in spec/factories/users.rb
/usr/src/app/spec/factories/users.rb:10:in `block (3 levels) in <top (required)>': undefined method `Factory' for #<Object:0x007fd5a0740ef0> (NoMethodError)
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload/helpers.rb:49:in `instance_eval'
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload/helpers.rb:49:in `factory_set'
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload/helpers.rb:28:in `factory'
from /usr/src/app/spec/factories/users.rb:10:in `block (2 levels) in <top (required)>'
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload.rb:41:in `instance_eval'
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload.rb:41:in `block (2 levels) in run'
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload.rb:40:in `each'
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload.rb:40:in `block in run'
from /usr/local/bundle/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
from /usr/local/bundle/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
from /usr/local/bundle/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload.rb:39:in `run'
from /usr/local/bundle/gems/factory_girl-preload-2.3.1/lib/factory_girl/preload/rspec2.rb:9:in `block (2 levels) in <top (required)>'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:378:in `instance_exec'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/example.rb:378:in `instance_exec'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb:357:in `run'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1660:in `block in run_hooks_with'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1660:in `each'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1660:in `run_hooks_with'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1626:in `with_suite_hooks'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:114:in `block in run_specs'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/reporter.rb:77:in `report'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:113:in `run_specs'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:89:in `run'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
from /usr/local/bundle/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'
from /usr/local/bundle/gems/rspec-core-3.3.2/exe/rspec:4:in `<main>'
/usr/local/bin/ruby -I/usr/local/bundle/gems/rspec-core-3.3.2/lib:/usr/local/bundle/gems/rspec-support-3.3.0/lib /usr/local/bundle/gems/rspec-core-3.3.2/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed
fnando commented
I think you're using it wrong: there's no Factory
. It's FactoryGirl.create
, or simply create
.
ricardopacheco commented
@fnando of course, my bad! thanks