Skip to content

Instantly share code, notes, and snippets.

@johan--
Forked from grantspeelman/Gemfile
Created March 6, 2016 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johan--/a3df41a0accf31547dae to your computer and use it in GitHub Desktop.
Save johan--/a3df41a0accf31547dae to your computer and use it in GitHub Desktop.
Example Gemfile files preparing for the next rails upgrade

Preparing for rails 5

These files are examples of how you can start running your code against rails 5 in parallel while not affecting your ability to continue developing.

You will be able to:

  • run rails 5 server
  • run your specs against rails 5
  • mark specs broken rails 5 specs
  • find gems that don't have a upgrade path (yet)
  • make decision with rails 5 in mind
@next_upgrade ||= false
source 'https://rubygems.org'
if @next_upgrade
gem 'rails', '5.0.0.beta3'
gem 'rails-controller-testing' # https://github.com/rails/rails-controller-testing
else
gem 'rails', '~> 4.2.5.1'
end
# rest of gems below ....
# examples of wrapping other gems
if @next_upgrade
gem 'paranoia', :github => "radar/paranoia", branch: 'core'
gem 'devise', :github => 'plataformatec/devise', :branch => 'master'
else
gem 'paranoia', '~> 2.0'
gem 'devise'
end
# BUNDLE_GEMFILE=Gemfile-next bundle install
@next_upgrade = true
main_gemfile = File.expand_path(File.dirname(__FILE__) + '/Gemfile')
eval File.read(main_gemfile), nil, main_gemfile
# do this only once so you have a starting lock file for the upgrade
cp Gemfile.lock Gemfile-next.lock
# update your Gemfile-next.lock to rails 5
# * resolved conflicts.
# * choose compatible rails 5 gems
# * notify gem authors if incompatible
# * fork the gem if you have to and create pull request for gem authors
BUNDLE_GEMFILE=Gemfile-next bundle update
#!/usr/bin/env bash
# a little helper script to use when installing new gems to keep both lock files up to date
bundle install # install gems for rails 4, creates Gemfile.lock
BUNDLE_GEMFILE=Gemfile-next bundle install # install gems for rails 5, creates Gemfile-next.lock
## now you can run commands between rails 4 and 5
bundle install # install gems for rails 4, creates Gemfile.lock
BUNDLE_GEMFILE=Gemfile-next bundle install # install gems for rails 5, creates Gemfile-next.lock
bundle exec rails s # runs code with rails 4
BUNDLE_GEMFILE=Gemfile-next bundle exec rails s # runs code with rails 5
bundle exec rspec # runs tests against rails 4
BUNDLE_GEMFILE=Gemfile-next bundle exec rspec # runs tests against rails 5
# etc
RSpec.configure do |config|
# "config.filter_rails_from_backtrace!" this option does not seem to work anymore
if Rails.version >= '5'
config.include Rails::Controller::Testing::TestProcess
config.include Rails::Controller::Testing::TemplateAssertions
config.include Rails::Controller::Testing::Integration
# exclude tests that do not work on rails 5
c.filter_run_excluding :rails5_broken => true
end
end
## marking a spec as broken on rails 5 to be fixed at another time
# describe "group 1", :rails5_broken => true do
## example of marking on a "it"
# it "does another thing", :rails5_broken => true do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment