It's happened to me to be barked at by dogs when riding my bike, but so far I've been lucky not to be bitten.
One good way to avoid being bitten by dogs is indeed to use pepper sprays-especially if you can spray while riding.
Or simply ignore the dogs, this often works great ;-)