Home>

I'm a rails turotial student,
Chapter 7
7.3.4 Test at failure
The bundle exec rake test did not succeed and the test did not proceed.
Is it because of a place that doesn't stop if it is moving normally?
If i am searching for a person who has the same symptom, you may not be able to find it.

I would appreciate any professor.

Error message
ERROR ["test_invalid_signup_information", UsersSignupTest, 0.425589790000231]
 test_invalid_signup_information # UsersSignupTest (0.43s)
NameError: NameError: undefined local variable or method `user 'for #<UsersSignupTest: 0x00000000061a7998>
        Did you mean? Users
            test/integration/users_signup_test.rb: 7: in `block in<class: UsersSignupTest>'
            test/integration/users_signup_test.rb: 7: in `block in<class: UsersSignupTest>'
 FAIL ["test_email_validation_should_reject_invalid_addresses", UserTest, 0.6627793839998048]
 test_email_validation_should_reject_invalid_addresses # UserTest (0.66s)
        "user @ example, com" should be invalid
        test/models/user_test.rb: 34: in `block (2 levels) in<class: UserTest>'
        test/models/user_test.rb: 32: in `each '
        test/models/user_test.rb: 32: in `block in<class: UserTest>'
  16/16: [=================================] 100% Time: 00:00:00, Time : 00:00:00
Finished in 0.67250s
16 tests, 30 assertions, 1 failures, 1 errors, 0 skips
Applicable source code

In the test/integration/users_signup_test.rb file

require 'test_helper'
class UsersSignupTest

Change users to user. . . .

Supplemental information (FW/tool version etc.)

cloud9 IDE
Rails 5.1.6
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

  • Answer # 1

    As shown in the error message, the variableuserdoes not exist here.

    I would like to check the total number of users, that is,'User.count'.

  • Answer # 2

    It seems that the version of the rails tutorial I have been practicing so far was old, so I was looking at the 4.2 version, and the 5.1 version was correct to proceed. After reviewing everything from Chapter 5 and proceeding, I resolved myself.
    Probably the way of writing the code was wrong from around 6.2 in Chapter 6.

Related articles