Depending on the reason for checking for the gem, it seems that it would be nice to lay out a package with your application on the script. Then check the script. Thus, you can be sure that access to the gem environment will be as close as possible (or even identical) to the user's method.
Using code similar to what Engel posted on this other SO thread seems like a good way to do this when you are in a shell.
source share