Rails5 Rspec test error ArgumentError: Factory not registered: user

Introduction

When I ran "bundle exec rspec spec / system / tasks_spec.rb" on the terminal in Chapter 5-8 of the Ruby on Rails5 Quick Learning Practice Guide, I was addicted to the following error. It is the memorandum.

Problems / errors that are occurring

Failures:

  1)Task management function list function display When user A is logged in, the tasks created by user A are displayed.
     Failure/Error: user_a = FactoryBot.create(:user, name: 'User A', email: '[email protected]')
     
     ArgumentError:
       Factory not registered: user
     
     # /Library/Ruby/Gems/2.6.0/gems/factory_bot-4.11.1/lib/factory_bot/registry.rb:24:in `find'
     # /Library/Ruby/Gems/2.6.0/gems/factory_bot-4.11.1/lib/factory_bot/decorator.rb:10:in `method_missing'
     # /Library/Ruby/Gems/2.6.0/gems/factory_bot-4.11.1/lib/factory_bot.rb:100:in `factory_by_name'
     # /Library/Ruby/Gems/2.6.0/gems/factory_bot-4.11.1/lib/factory_bot/factory_runner.rb:12:in `run'
     # /Library/Ruby/Gems/2.6.0/gems/factory_bot-4.11.1/lib/factory_bot/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
     # ./spec/system/tasks_spec.rb:7:in `block (3 levels) in <top (required)>'

Finished in 5.33 seconds (files took 1.31 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/system/tasks_spec.rb:19 #Task management function list function display When user A is logged in, the tasks created by user A are displayed.

Cause / Solution

Directory name misspelled

Positive factories
Wrong factries

You have to be careful not to make a typo in the directory name ...

Recommended Posts

Rails5 Rspec test error ArgumentError: Factory not registered: user
An example of a FactoryBot [KeyError: Factory not registered: "user"] error
[Rails] Test with RSpec
[Ruby On Rails] Error in test using RSpec MySQL client is not connected
[Rails] Test code using Rspec
[Rails] About Rspec response test
[Rails5] Rspec -Unit test when nesting-
Data is not registered in Rails.
Let's unit test with [rails] Rspec!
[Ruby on Rails] View test with RSpec
[Ruby on Rails] Controller test with RSpec
RSpec error resolution undefined method'name' in'user' factory
[Ruby on Rails] Model test with RSpec
rails test fails with database reference error
I rewrote the Rails tutorial test with RSpec
[For beginners] Test devise user registration with RSpec
Introducing Rspec, a Ruby on Rails test framework