Skip to content

Instantly share code, notes, and snippets.

@bjjb
Created December 5, 2012 22:54
Show Gist options
  • Save bjjb/4220252 to your computer and use it in GitHub Desktop.
Save bjjb/4220252 to your computer and use it in GitHub Desktop.
How to get the path to an arbitrary file from a Rubygem
# Includes a file from a gem. Useful for reusing test helper files from the gems
# you're writing functionality for.
def gem_file(gem, file, *gem_requirements)
File.join(Gem::Dependency.new(gem, *gem_requirements).to_spec.gem_dir, file)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment