If you are trying to do this from ruby, you can use the built-in RubyGem method. Older versions provide the Gem.available?('capybara') method, which returns a boolean, but this is deprecated. The recommended method is now to use (provided that you use a version that supports it):
Gem::Specification::find_by_name('capybara')
http://rubygems.rubyforge.org/rubygems-update/Gem/Specification.html
Update
If you need a boolean result, you can use .find_all_by_name() and check if the resulting array is empty:
if Gem::Specification::find_all_by_name('capybara').any?
source share