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 user model code is:
class User < 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
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 ?
Blockquote