Rafael Nadal and Feliciano Lopez beat Great Britain to send Spain into the Davis Cup final for the first time since 2012.