title: Rspec fails for Devise model custom validation for valid_password?
body: <p>I am using devise gem(authentication). I am implementing custom validation for reset password.  User can not reset there new password with existing password.
  in <strong>user</strong> model code is:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code> class User &lt; ActiveRecord::Base
       include ActiveModel::ForbiddenAttributesProtection
       validate  :check_existed_password                               
  
        def check_existed_password
          if User.find_by_email(self.email).valid_password?(password)
            errors.add(:password, "password already existed, try other")
          end
        end
      end                               
  </code></pre>
  
  <p>
  
  <p>After running rspec, I am getting error:  Failure/Error: no_email_user.should_not be_valid
     NoMethodError:
         undefined method `valid_password?' for nil:NilClass. All pre-existing test cases in user_spec.rb file is getting fail. any suggestion ?</p>
  
  <blockquote>
    <p>Blockquote</p>
  </blockquote>