use gem list -i

gem actually includes an exit-status option