If someone is careful, such a ruse won't work. It was a move of desperation (like many of Kirk's more successful stratagems) that could have easily failed. Kirk used it because, in his opinion, there was no other viable option that could save his ship.
He also wasn't thinking entirely clearly, having been badly wounded earlier in that episode.
It is clearly shown that Star Trek sensors, when faced with a ship of known configuration and/or design, can detect when there is energy being provided to different systems. Thus, an alert enemy ship could have detected that the phasers were powered.
The enemy ship, along with the enemy agent on the Enterprise bridge, were on a suicide mission. Kirk could have discerned this based on the activities of the agent as well as the ship - if the ship was advanced enough to sustain the speed and ferocity it had been displaying while still retaining defensive capabilities (including a detailed sensor watch) it would have had to be far above and beyond anything Kirk had heard of. He reasoned that it wasn't caring much for defense, and would likely see the apparent loss of power (loss of lights, cessation of maneuvering) as a true loss of power, not a feint.
In short, Kirk's foe didn't care if it was a ruse, they wanted blood. They were already dead and just wanted to take someone with them. Kirk realized this intuitively, and set a desperate trap.