I think that for these kinds of potential situations, there's nothing wrong with being prepared with several options. Yelling, getting the bike between you and the dog, etc., are great first options. But if those things fail, it doesn't hurt to have a back-up plan (hopefully one that you never have to use, but another option nonetheless). I don't look at something like pepper spray as a first option, but I do see it as part of a fall-back plan if other immediately available options fail.