rails test email validation error due to password testing? -


After the latest version of Michael Hart's Rail Guide,

I have the following test file in my test / test.

model / user_test.rb

  is required 'test_helper' class UserTest & lt; ActiveSupport :: Test Season Def Setup # prevails # @ user = User.new (name: "example name", email: "example@example.com") # Password and password_conformation after has_secure_password in User.rb @user = User.new (name is implemented: "example name", email: "example@example.com", password: "foobar", password_confirmation: "foobar must be valid" @user claim ") end. ... # other tests # should be valid user testing. "Valid? Valid email address test for end # test first.last@foo.jp Alice + valid_addresses =% W [user@example.com USER@foo.COM A_US-ER@foo.bar.org "Email validation valid addresses Should accept "Bob@baz.cn] valid_addresses.each do | Valid_address | @ User.email = valid_address @ user.valid ?, "# {valid_address.inspect} must be valid" to end invalid email address test #test "email verification should invalidate invalid addresses" invalid_addresses =% W [ User @ example emphasis, com user_at_foo.org user.name@example Foo@bar_baz.com foo@bar+baz.com] invalid_addresses.each do | Invalid_address | @ User.email = invalid_address assert_not @ user.valid ?, "# {invalid_address.inspect} should be invalid" end end # The problem starts here !!!! # Exam Password Minimum Length 8 As "Test Password Must Have Minimum Length" user @ password = @ user.password_confirmation = "a" * 7 assert_not @ user.valid? Finally ... end of # and other tests  

While returning the bundle app rake trial it is returning for some reasons

  1) Failure: UserTest # test_email_validation_should_accept_valid_addresses [/Users/jackCHH/Desktop/Websites/cloudSolar/test/models/user_test.rb:49]: "user@example.com" should be valid 2) failure: UserTest # test_should_be_valid [/ users / jackCHH / Desktop /Websites/cloudSolar/test/models/user_test.rb:14]: Failed claim, no message given  

I started the problem after adding the test script to test the length of the password. I also added valid: password, length: {minimum: 8} to my model User.rb. If I remove the verification line in my model and password_leg test script, then the test passes again.

My email announcement @user right (example@example.com), so I'm not sure that this is why an invalid email

I'm doing wrong ?

I found the answer.

@user my announcement, both your password and password_confirmation is Foobar, only length 6. I set it so that the required minimum of 8 characters, so it gives an error. After

Change password

Isfoobr, the problem went resolved.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -