I think the only way I'd use pepper spray is if I could identify an upcoming attack plenty in advance, know that my assailant was unarmed, could nail him in he face with the spray from a good 10-15 feet out, and then outrun him after spraying without him ever being able to touch me. Of course this unfolding of events would have ME being the assailant, not the bad guy. So it's hypothetical at best.

Other than that scenario, I'd prefer to have a gun every time.