What year did Spain outlaw computer virus spreading?
Articles 197 bis and 197 ter of the Penal Code of Spain were enacted in 2015. See footnote in both articles. But these statutes outlaws only the unauthorized "virus spreading".
I am also interested in what the penalty would be
Imprisonment (between six months and two years). In the case of art. 197 ter, an alternative penalty is a fine of three to eighteen months (I believe in Spain fines are based on what is known as "Minimum Interprofessional Salary").
having read through their criminal Articles it appears to only cover hacking.
If/when "virus spreading" involves unauthorized access to a system, the matter falls within scope of art. 197 bis. As enacted, the difference between hacking tools and malware is inconsequential: Either program is lawful as long as the element of authorized access is met and the program is not "conceived or adapted primarily for committing said crimes". See item a) of art. 197 ter.