RailsApps / rails-devise-pundit

Rails 5.0 starter app with Devise for authentication and Pundit for authorization.
http://railsapps.github.io/rails-devise-pundit/
483 stars 156 forks source link

rspec tests fail out of the box #40

Closed paulywill closed 6 years ago

paulywill commented 6 years ago

Am I missing something?

I just followed the instructions and left the secrets.yml as is.

Sign in
  user cannot sign in if not registered (FAILED - 1)
  user can sign in with valid credentials
  user cannot sign in with wrong email (FAILED - 2)
  user cannot sign in with wrong password (FAILED - 3)

Sign out
  user signs out successfully

User delete
  user can delete own account (PENDING: skip a slow test)

User edit
  user changes email address
  user cannot cannot edit another user's profile

User index page
  user sees own email address

User profile page
  user sees own profile
  user cannot see another user's profile

About page
  Visit the about page

Home page
  visit the home page

Navigation links
  view navigation links

Sign Up
  visitor can sign up with valid email address and password
  visitor cannot sign up with invalid email address
  visitor cannot sign up without password
  visitor cannot sign up with a short password (FAILED - 4)
  visitor cannot sign up without password confirmation
  visitor cannot sign up with mismatched password and confirmation

User
  should respond to #email
  #email returns a string

UserPolicy
  index?
    denies access if not an admin
    allows access for an admin
  show?
    prevents other users from seeing your profile
    allows you to see your own profile
    allows an admin to see any profile
  update?
    prevents updates if not an admin
    allows an admin to make updates
  destroy?
    prevents deleting yourself
    allows an admin to delete any user

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) User delete user can delete own account
     # skip a slow test
     # ./spec/features/users/user_delete_spec.rb:18

Failures:

  1) Sign in user cannot sign in if not registered
     Failure/Error: expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email'
       expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me". (However, it was found 1 time using a case insensitive search.)
     # ./spec/features/users/sign_in_spec.rb:13:in `block (2 levels) in <top (required)>'

  2) Sign in user cannot sign in with wrong email
     Failure/Error: expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email'
       expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me". (However, it was found 1 time using a case insensitive search.)
     # ./spec/features/users/sign_in_spec.rb:35:in `block (2 levels) in <top (required)>'

  3) Sign in user cannot sign in with wrong password
     Failure/Error: expect(page).to have_content I18n.t 'devise.failure.invalid', authentication_keys: 'email'
       expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me". (However, it was found 1 time using a case insensitive search.)
     # ./spec/features/users/sign_in_spec.rb:46:in `block (2 levels) in <top (required)>'

  4) Sign Up visitor cannot sign up with a short password
     Failure/Error: expect(page).to have_content "Password is too short"
       expected to find text "Password is too short" in "Toggle navigation Home About Edit account Sign out × Welcome! You have signed up successfully. Welcome Users: 1 registered"
     # ./spec/features/visitors/sign_up_spec.rb:41:in `block (2 levels) in <top (required)>'

Finished in 3.63 seconds (files took 5.04 seconds to load)
31 examples, 4 failures, 1 pending

Failed examples:

rspec ./spec/features/users/sign_in_spec.rb:11 # Sign in user cannot sign in if not registered
rspec ./spec/features/users/sign_in_spec.rb:32 # Sign in user cannot sign in with wrong email
rspec ./spec/features/users/sign_in_spec.rb:43 # Sign in user cannot sign in with wrong password
rspec ./spec/features/visitors/sign_up_spec.rb:39 # Sign Up visitor cannot sign up with a short password
paulywill commented 6 years ago

@DanielKehoe did something change since this change? : https://github.com/plataformatec/devise/issues/3243

paulywill commented 6 years ago

@DanielKehoe, as per this Stackoverflow post, the 'email' keyword passes the first 3 failing tests if changed to 'Email'.

The last test is using 'please' as the test password (6 chars), but the error message if the password is too short indicates the following:

1 error prohibited this user from being saved:
Password is too short (minimum is 6 characters)
DanielKehoe commented 6 years ago

Thanks for the helpful contribution of the fix. Everyone benefits!