Skip to content

Authentication generator doesn't seem to be working with RSpec #532

@thiagorossi

Description

@thiagorossi

Description

I am not able to use bin/rails generate authentication after installing factory_bot_rails with RSpec.

I am opening this ticket here because when I removed it from the Gemfile the generator worked with test-unit. I hope I am not in the wrong place. It might be factory_bot or maybe even rspec-rails.

When I comment out factory_bot_rails from the Gemfile it also works, though it generate fixtures:

    ...
       rails  generate migration CreateSessions user:references ip_address:string user_agent:string --force 
      invoke  rspec
      create    spec/models/user_spec.rb
      create    spec/fixtures/users.yml

It works fine with other generators like model and scaffold, except when I use authentication generator.

Thanks!

Reproduction Steps

  1. Create a new project using Rails 8.0.2.
  2. Add factory_bot (or allow it to be installed by the factory_bot_rails in a future step).
  3. Install faker. - Probably unrelated, but these were my steps.
  4. Install rspec-rails and run bin/rails generate rspec:install.
  5. Add or remove config.include FactoryBot::Syntax::Methods from rails_helper.rb or spec_helper.rb. I tried a few combinations.
  6. Run bin/rails generate authentication (with or without --pretend).

Expected behavior

Authentication to be generated.

Actual behavior

I get this error:

    ...
       rails  generate migration CreateSessions user:references ip_address:string user_agent:string --force 
      invoke  rspec
      create    spec/models/user_spec.rb
       error    factory_bot [not found]

System configuration

factory_bot_rails version: 6.4.4
factory_bot version: 6.5.1
rails version: 8.0.2
ruby version: 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [aarch64-linux]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions