Maybe cats' olfactory senses interpret the smell of a cucumber as that of a predator they're instinctively afraid of.
I'd test this on Maddy, but I don't like cucumbers enough to buy one and eat it (any tests would be carried out with the cucumber placed on a clean surface so it wouldn't have to be thrown out).
Mind you, Maddy being Maddy, she's often unimpressed with things cats are supposed to pay attention to. For instance, if I offer to play with her using the laser toy I used to use at the cat shelter I volunteered at, she just looks at me like I'm terminally stupid, with an expression of "Oh, come on, I know that's a fake, toss me something real to play with!" (she prefers McDonalds cheeseburger wrappers).