Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active June 29, 2023 15:58
Show Gist options
  • Save Integralist/0bc61ef9827232605b55 to your computer and use it in GitHub Desktop.
Save Integralist/0bc61ef9827232605b55 to your computer and use it in GitHub Desktop.
Testing a Ruby Gem

Version 1

# Long way of doing things (new files need to be added to staging area *before* building the gem)
git add . && gem build my_gem.gemspec && gem install my_gem-0.0.0.gem

Version 2

# If using Bundler to generate the gem (rake task does the same as above)
git add . && rake install

Version 3

# This way you don't need to rebuild the gem after every change
gem 'my_gem', :path => '/Users/me/path/to/my_gem'
gem 'some_gem', :git => 'https://github.com/User/SomeGem.git', :branch => 'some-branch'
bundle exec my_gem_command

Note: if you point to a local gem "A" and that gem internally references/requires another local gem "B" which you wish to run locally, then you need to open the Gemfile for the top-level application and modify it to use the same Bundler trick again gem "b", :path => "path/to/local/b/gem"

@sambecker
Copy link

Thank you! This was really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment