Skip to content

Docs for Testing-Rails need update for request specs #319

@brentgreeff

Description

@brentgreeff

This page https://github.com/Sorcery/sorcery/wiki/Testing-Rails needs updating.

For request specs (I dont need helpers for system specs - and I dont use controller specs)

I added:

config.include Sorcery::TestHelpers::Rails::Request, type: :request - in rails_helper.rb

-  post 'login' => "user_sessions#create"
+  post 'login' => "user_sessions#create", as: 'user_sessions'

I had to make this change - because I got undefined method user_sessions_url

Then using pry I figured out that the password assumed is secret - which is not a good password since my user model has

  validates :password, length: { minimum: 8 }, if: -> {
    new_record? || changes[:crypted_password]
  }

In my test - I added

User.class_eval do
  clear_validators!
end
  • which I dont really want to do.

Configuration

  • Sorcery Version: 0.16.3
  • Ruby Version: 3.0.4p208
  • Framework: rails-7.0.3.1
  • Platform: OSX

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions