Skip to content

Rails 8 test helpers do not work with fixtures and RSpec #5794

@Fh-Ndiritu

Description

@Fh-Ndiritu

I am still running into this issue even after the merge of a related fix

Environment

  1. Ruby 3.4
  2. Rails 8.0.2
  3. Devise 4.9.4

Test setup

  1. RSpec with fixtures (users.yml)
  2. devise_for :users is already set in routes
  3. Integration and Controller helpers are configured in rails_helper

Error on running on controller tests

   
   RuntimeError:
     Could not find a valid mapping for #<User id: ...

Solution that worked for me

Add to spec_helper

  # TODO Remove when Devise fixes https://github.com/heartcombo/devise/issues/5705
  config.before(:each, type: :controller) do
    Rails.application.reload_routes_unless_loaded
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions