Narrated Jabir: A bedouin came to the Prophet (peace be upon him) and gave a pledge of allegiance for embracing Islam. The next day he came with fever and said (to the Prophet (peace be upon him), “Please cancel my pledge (of embracing Islam and of immigrating to Medina).” The Prophet (peace be upon him) refused (that request) three times and said, “Medina is like a furnace, it expels out the impurities (bad persons) and selects the good ones and makes them perfect.”
Sahih al-Bukhari, Vol. 3, Book 29, Hadith 17