Skip to content

Conversation

@rodrigotoledo
Copy link
Contributor

This change addresses an issue where running the factory_bot generator could result in a factory_bot [not found] error. The problem occurred due to missing generator definitions and template files.

With this update, the authentication generator is properly defined and includes the necessary templates, ensuring that the users.rb factory file is generated regardless of whether the project is using RSpec (spec/factories) or Minitest (test/factories). This guarantees consistent behavior and avoids generator errors in environments without a spec directory.

Previously, projects without a spec directory or with incomplete generator/template setup would fail when invoking factory_bot generators, making it impossible to scaffold the necessary factory files automatically.

  • Added the missing factory_bot:authentication generator definition.
  • Included users.rb template under templates directory.
  • Implemented logic to detect the test framework and place the generated factory file in the correct directory (spec/factories or test/factories).
  • Ensured generator runs successfully regardless of the presence of a spec directory.

This change addresses an issue where running the `factory_bot` generator could result in a `factory_bot [not found]` error.
The problem occurred due to missing generator definitions and template files.

With this update, the authentication generator is properly defined and includes the necessary templates, ensuring that the `users.rb` factory file is generated regardless of whether the project is using RSpec (`spec/factories`) or Minitest (`test/factories`).
This guarantees consistent behavior and avoids generator errors in environments without a `spec` directory.

Previously, projects without a `spec` directory or with incomplete generator/template setup would fail when invoking `factory_bot` generators, making it impossible to scaffold the necessary factory files automatically.

- Added the missing `factory_bot:authentication` generator definition.
- Included `users.rb` template under `templates` directory.
- Implemented logic to detect the test framework and place the generated factory file in the correct directory (`spec/factories` or `test/factories`).
- Ensured generator runs successfully regardless of the presence of a `spec` directory.
@neilvcarvalho
Copy link
Member

Closing in favor of #542 - but I'll give you credits!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants