Adam Rooney's 12th goal of the season three minutes from the end moved Aberdeen to within a point of Celtic and seven points clear of Hearts.