You gotta know what you're doing. In some ways, it's like a gun - the gun without knowledge is ineffective in a 'high stress' situation like a bear attack.
Bear spray is effective. It works. There are literally hundreds of cases well documented that demonstrate this. However, here's some things you should really know:
1 - it's more effective on grizzlies and browns than it is on black bears.
2 - It does work on black bears, BUT - in many many cases the black bear returned within 5 - 10 minutes and continued the attack. If you spray a black bear, use the time to get your gun ready or leave the area. Buy a BIG can because you may have to spray the bear 2 or 3 times before you make it to saftey.
3 - once fired, even once - the can will probably lose pressure. If you want to 'test' it - buy a seperate test can.
4 - do not aim it like a pistol. That's begging for a face full of spray. Fire it from about hip level with your arm forward. There's no need to aim - just walk the spray onto the target.
5 - Range is everything. Too many people fire too soon to do any good at all. Forget what it says on the can - the bear has to be very close to you, as in 15 - 20 ft max. And 15 is better.
6 - once you fire - begin to move upwind, or if the wind is in your face, to one side. Not only will this help to keep the spray out of your face, but even a slight change in position helps to disorient the bear as to where you are.
7 - do not touch your hands to your face after spraying.
Guns are not effective 100 percent of the time by any stretch of the imagination. Many people have shot an attacking bear, only to be mauled anyway. A griz with its heart shot will live up to 60 seconds anyway, and in that time he can do a world of hurt to you.
AND - the biggest problem with guns is they're often not ready right when you need 'em. A bear coming out of the woods can be on you faster than you can unsling a gun and rack a round in many cases. Lots of guys have been found dead beside their unfired gun.
But - lets face it, in the hands of a guy who is skilled in it's use and ready for the bear it's probably the best choice.
So -
Pepper spray:
Pros -
Very fast to use. Keep it on your belt and you can get it into action very fast, faster than a rifle in most cases.
Don't have to worry about 'whats behind the bear'.
Can be carried places guns cannot.
Easy to keep with you - you don't put it down like a rifle or shotgun when you're doing something.
Light.
Suitable for non-shooters (with training.).
Disadvantages -
Bear may well come back.
Is VERY close range only - hard to use on a bear you're worried about but hasn't attacked yet.
May somewhat incapacitate you as well if you get a bunch of it in your face. Even if it doesn't, it's going to irritate your eyes a bit.
Guns -
pros:
Tends to kill bears dead. After which, they rarely attack again.
noise and fire of a gun at close range is as much of a disorienting feature as the spray, at ranges under 15 yards or so. Which is a lot more than 15 feet.
Can deal with a bear farther out - 20 yards if it's being hostile and you can kill it and end the threat without waiting for it to actually turn and attack if you feel it's a danger.
Cons -
Slow to bring into action if you're not ready for the attack.
Requires a fair bit of practice to be good with.
If you wound the bear, it will just attack harder (griz only).
You have to worry about hitting others if you're not alone.
Weighs a lot - there's a tendancy to want to put it down 'for a minute' when you're doing stuff.
Not allowed in some places.
A good rule of thumb is that there is no such thing as a 100 percent bear solution. Use a variety of tools - including keeping your camp properly and approaching likely bear feeding areas properly - to maximize your saftey. Guns are part of the solution, so is pepper spray, but BOTH of those are for last -ditch efforts .. it's far better to avoid the confrontation in the first place.
So study a little about bears, learn their habits a bit, and use your head.
(note - one interesting trick i've read about that seems to work very well in many documented cases is wear a hat. If the bear charges without warning and surprises you, grab the hat and fling it into the bears path (low is better - you don't want it going over them). They will often take a moment to attack the hat - batting at it or chewing it. It only buys you about 2 seconds, but often that is enough time to get your gun or pepper spray ready for use. It can be a useful trick in those cases where you're completely surprised by a bear at close range. )