Normally when you’re working with a Ruby project with Bundler you write a file called
bundle install and then invoke various commands with the
bundle exec prefix. However what if you would like to be able to work with different versions of gems over a longer period of time? In that case being able to use multiple Gemfiles within a single branch can help.
Bundler supports passing an environment variable called
BUNDLE_GEMFILE to all of its commands. Here is an example how we can tell it to use a file called
BUNDLE_GEMFILE=Gemfile-rails4 bundle install --path vendor/bundle-rails4
You can then run tests in the similar way:
BUNDLE_GEMFILE=Gemfile-rails4 bundle exec rake spec
On Semaphore, I recommend creating a new project with the same repo and using build commands tailored for the custom Gemfile.