Skip to content

Conversation

neilvcarvalho
Copy link
Member

I couldn't push to #540, so I'm opening a new PR with the original commit and a new one.


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 neilvcarvalho force-pushed the fix-authentication-generator branch 2 times, most recently from 35ad6fc to 10d09ef Compare September 5, 2025 20:54
@neilvcarvalho neilvcarvalho force-pushed the fix-authentication-generator branch from 10d09ef to 8820e05 Compare September 5, 2025 21:00
@neilvcarvalho neilvcarvalho merged commit b6c4e8d into main Sep 5, 2025
20 checks passed
@neilvcarvalho neilvcarvalho deleted the fix-authentication-generator branch September 5, 2025 21:10
password_confirmation { "password123" }
email_address { "user#{SecureRandom.hex(3)}@example.com" }
end
end
Copy link

@jeromedalbert jeromedalbert Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this file is never used. I made PR #544 to remove it.

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.

3 participants