NoMethodError: undefined method 'name' in 'project' factory
mellansquare opened this issue · comments
Hi,
I'm using Rails 4.2.0 (for reasons) and ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]. We had to downdate (opposite of update) my rails version and now my specs keep throwing up a NoMethodError. I've tried rake db:schema:dump, rake dp:test:prepare as per another question asker and that didn't work. Please can you help me fix the issues that have come up as a result of having to backdate my rails version.
Here's the whole error from running my spec:
`An error occurred while loading ./spec/features/searching_spec.rb.
Failure/Error: name 'Example project'
NoMethodError:
undefined method 'name' in 'project' factory
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/definition_proxy.rb:97:in `method_missing'
./spec/factories/project_factory.rb:3:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/syntax/default.rb:18:in `instance_eval'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/syntax/default.rb:18:in `factory'
./spec/factories/project_factory.rb:2:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/syntax/default.rb:49:in `instance_eval'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/syntax/default.rb:49:in `run'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/syntax/default.rb:7:in `define'
./spec/factories/project_factory.rb:1:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/find_definitions.rb:20:in `block (2 levels) in find_definitions'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/find_definitions.rb:19:in `each'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/find_definitions.rb:19:in `block in find_definitions'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/find_definitions.rb:15:in `each'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot-5.0.2/lib/factory_bot/find_definitions.rb:15:in `find_definitions'
/usr/local/rvm/gems/ruby-2.3.4/gems/factory_bot_rails-5.0.1/lib/factory_bot_rails/railtie.rb:26:in `block in class:Railtie'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.0/lib/rails/application/finisher.rb:62:in `block in module:Finisher'
/usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
/usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/rvm/gems/ruby-2.3.4/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
./config/environment.rb:5:in `<top (required)>'
./spec/rails_helper.rb:4:in `require'
./spec/rails_helper.rb:4:in `<top (required)>'
./spec/features/searching_spec.rb:1:in `require'
./spec/features/searching_spec.rb:1:in `<top (required)>'
No examples found.
Finished in 0.0004 seconds (files took 5.58 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples`
I'm guessing you figured this out, since you closed the issue. But just in case, this is probably the same as #313. We deprecated static attributes in factory_bot 4.11 and removed them in 5.0. Let me know if you have any more trouble with this.