Hm, what exactly do you mean? I don't see an already set factory in the spec.

If you mean line 40: that's the only solution I found so far to fake we are requesting an update. It only works if the user object is fresh from the database.

The thing is if I use a let for example, the password instance variable is set and stays set in the spec example. That is not what I want. In the controller, when the submission of an empty password and password confirmation arrives, the @user variable has no password set yet. So it works correctly with has_secure_password which overwrites password only if it is not blank.

I didn't find a better solution for the model spec yet.