Skip to content

Instantly share code, notes, and snippets.

@jonathanroehm
Last active October 10, 2023 01:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanroehm/70749fb6f29c61d0af7c7ed9cc233f79 to your computer and use it in GitHub Desktop.
Save jonathanroehm/70749fb6f29c61d0af7c7ed9cc233f79 to your computer and use it in GitHub Desktop.
How to test a gem you're working on locally in your development host ruby on rails app

Setting up your bundle config to allow your host app to use the local version of your gem

What we don't want:

Having to test your gem on your host app after having to commit changes to your gem... and then having to rebundle your gemfile ... which forces you to refer to your gem-in-process like:

gem 'nfg_ui', git: 'https://github.com/network-for-good/nfg_ui', branch: 'feature/some_feature_branch_that_im_working_on'

And then have to:

$ bundle update gem_name`

None of that annoying stuff! Let's instead allow our gem to pick up immediate changes without having to rebundle from github.


Config bundler to use your local gem version:

Format:

$ bundle config [gem name] [path to the the local version of your gem]

Example using a real gem

This a gem that I'm working on and have cloned to my hardrive

$ bundle config local.nfg_ui /Users/jonathanroehm/projects/nfg_ui

Disabling local usage of your gem

Tell bundler config to STOP using your local gem version:

Format:

$ bundle config --delete local.[your gem name]

Example using a real gem

This deletes the config for the same gem I referred to above:

$ bundle config --delete local.nfg_ui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment