I have tried exposing a mole 15 times. All while in democracy. Failed all 15 times. Civ i tried to expose mole on always declared war after. Even a 2 city civ which was gracious declared war after.
Personally I have found most espionage options completely useless.
To think of it, why the hell would trying to expose a enemy spy in your country cause another civ to declare war? I can see if they did it and found a spy of yours in their country. But automatically declaring war on u when u attempt to find out if they have a spy in your country