On November 23rd, the BOE (Official State Gazette) published the requirement of a PCR test for citizens arriving from high-risk countries.
According to this October 13 EU Recommendation (https://eur-lex.europa.eu/legal-content/ES/TXT/?uri=uriserv:OJ.L_.2020.337.01.0003.01.SPA), high-risk (or red-level) countries, which have a cumulative COVID-19 case reporting rate in the past fourteen days equal to or higher than 50, and a positive COVID-19 test rate of 4% or more, or in case the cumulative rate of notification of COVID-19 cases in the last fourteen days is higher than 150 per 100,000 population, will be affected by this rule.
To see the cumulative index, you can consult the following webpage: https://www.ecdc.europa.eu/en.
Therefore, before entering Spain, travellers must fill in this form (https://www.spth.gob.es/), which will include a question about the PCR test when the obligation becomes effective.
Notice published on November 24th, 2020 ; valid untill midnight of December 31th, 2020