Testing an unreleased version of a gem? Want to develop 2 unreleased projects that are based on each other and not have to worry about the following?
gem 'some_gem', path: '../my-dev-snapshot'
Gemfile as such will screw with your project history, so we want
the version of
Gemfile as it will be when the gem is released, keeping that
version in our “git memory”. See the following:
bundle config local.some_gem "$(realpath ../my-dev-snapshot)"
This will allow your
Gemfile to remain pristine without the
hacks so others can set their own path to the gem source directory.
The gem, in this case
some_gem, must be pointed at a git repository. In this
case, it would need to be:
gem 'some_gem', github: 'foo/bar', branch: 'master'
This would allow us not only to optimize network traffic so we don’t make calls out to the git repository all the time, but also point it toward a local working copy.
There is an additional caveat, though. The given branch — in the example,
master — must match the branch of the current working copy at the path
bundle config from earlier.
Written by David Alexander who lives and works in the Indianapolis area building useful things. Follow him on Twitter