Hadithcore
Sahih al-Bukhari, 4742
sahih

Narrated Ibn `Abbas:

Regarding the Verse: "And among men is he who worships Allah's as it were on the very edge." (22:11). A man used to come to Medina as if his wife brought a son and his mares produces offspring. He would say, "This religion (Islam) is good," but if his wife did not give birth to a child and his mares produced no offspring, he would say, "This religion is bad."

حَدَّثَنِي إِبْرَاهِيمُ بْنُ الْحَارِثِ، حَدَّثَنَا يَحْيَى بْنُ أَبِي بُكَيْرٍ، حَدَّثَنَا إِسْرَائِيلُ، عَنْ أَبِي حَصِينٍ، عَنْ سَعِيدِ بْنِ جُبَيْرٍ، عَنِ ابْنِ عَبَّاسٍ ـ رضى الله عنهما ـ قَالَ ‏{‏وَمِنَ النَّاسِ مَنْ يَعْبُدُ اللَّهَ عَلَى حَرْفٍ‏}‏ قَالَ كَانَ الرَّجُلُ يَقْدَمُ الْمَدِينَةَ، فَإِنْ وَلَدَتِ امْرَأَتُهُ غُلاَمًا، وَنُتِجَتْ خَيْلُهُ قَالَ هَذَا دِينٌ صَالِحٌ‏.‏ وَإِنْ لَمْ تَلِدِ امْرَأَتُهُ وَلَمْ تُنْتَجْ خَيْلُهُ قَالَ هَذَا دِينُ سُوءٍ‏.‏

References2 variants
In-Book Reference
Book 65, Hadith 264
USC-MSA web (English) reference
Vol. 6, Book 60, Hadith 266 (deprecated numbering scheme)