Actual bear attacks are rare. I am certain that if a bear is making a bluff charge, that bear spray would deter it. Then. again, if it is a bluff charge, it isn't planning to actually attack anyways (although it is impossible to know at the time what the bears true intentions are). However, if the charge is REAL and the bear is intent on completing the task, I doubt that bear spray will do anything. In fact, unless you get a lucky shot that kills of cripples the bear instantly, a gunshot isn't likely to save your arse from harm although it may prevent the bear from finishing you off if the shot was lethal just not instant. The guy in this video would ahem been MUCH better of, IMO had he had his handgun with him than just the bear spray but guaranteed he would not have fair any worse.
https://www.youtube.com/watch?v=27e-pYDddDA When my Dad went sheep hunting2 he ALWAYS carried his Colt SAA .45 in a shoulder holster even though it is illegal in Canada to do so. It was not uncommon for a grizzly to stand up in the buck brush VETY close to them and if the horses spooked and threw him off, he would be left with his #### in his hand while the horse ran off with his rifle. He always said that the .45 would be like throwing rocks at a grizzly but would be better than nothing and he might just get a lucky shot.