password, hashed_password and validation

*** Disclaimer: I am new to rails myself. ***

if I ever attempt something like this in my User unit tests...

user = users(:user_jeff) assert user.valid?

I will get an assertion failure like this: 'Password is too short (minimum is 6 characters)'

Any suggestions as to what I SHOULD be doing?

I'm not sure what the "best practice" way of doing it is, but I was coming up against the same problem recently myself. I will probably eventually use one of the popular user management generators, but I wanted to implement it myself first, so that I understood properly the issues involved. I don't have time right now to give a detailed explanation of how I handled it, but the gist of it is this:

I created a separate Password class that was responsible for handling all password functionality. This class could be initialized either via the hashed password and salt (for when it is initialized from the database), or by passing it a plain text password. Rather than doing a "validates_length_of :password" in the user model, I did

Maybe I should also have mentioned that User also contains:

        def password=(password_)                 @password.password = password_         end