I used to play a lot on my former iMac, and it was more than ok. Some games I had to lower the settings but it worked well. Anything from blizzard will work well since they make Mac versions of their games, for everything else you can always use bootcamp. Make sure that your graphics card driver are the latest(on the windows side) ( from the graphic card website not the ones from Apple). It cost more but for decent gaming buy the iMac with the best graphic card you can afford and if you can swing that too, pick a model with ssd drive.
I sold my iMac then I built a gaming pc, it is a f.... monster but even if the gaming is a lot better, I still miss my iMac for everyday use.