Upgrading Ruby from 1.8.7 to 2.3.5

Updated . Posted . Visible to the public. Deprecated.

Suggested Workflow

Set the ruby version in .ruby-version to 2.3.5, then perform these steps one by one, fixing errors as they occur:

  1. Update gems as listed below, and bundle
  2. Boot a Rails console - see below for a list of changes you will probably need
  3. Run Specs with --backtrace option
  4. Run Cucumber features (with Geordi's --debug option)
  5. When all tests are green, look through your Gemfile and remove as many version constraints as possible.
  6. Boot the application in different environements to spot further issues, e.g. rails console staging

Gem updates

  • Replace ruby-debug with byebug or pry

  • Replace mysql with mysql2, '< 0.3'

  • Remove oniguruma

  • Remove net-ssh and net-scp

  • Remove fastercsv

  • Remove cucumber_spinner

  • Remove rspec_spinner

  • Update rspec to '< 2'

  • Lock haml to '= 3.1.7'

  • Unlock andand

  • Unlock rake

  • Lock test-unit to '= 1.2.3'

  • Lock database_cleaner to '< 1.3'

  • Lock cucumber to '< 2'

  • Lock launchy to '~> 2.1 '

  • Lock paperclip to '< 2.8'

  • Add capybara-screenshot and require it in Cucumber features. It will simplify debugging failing features.

    require 'capybara-screenshot/cucumber'
    
    Capybara::Screenshot.prune_strategy = { keep: 12 } # parallel_tests
    
  • TODO: Add rspec-patches gem from PH

Code changes

  • Remove UTF8 hints at the top of files
  • Pay tight attention to method privacy. Ruby 2.3 is more whiny about misusage, especially for Methods defined with define_method.
  • Use the spec_label implementation that works in Ruby 2
  • Update require statements in features/support/env.rb. Use more require_relative or require Rails.root.join('...')
  • Fix Float rounding issues with BigDecimal('12.3')
  • Use ' ' for nbsp helper instead of 0xC2.chr + 0xA0.chr
  • Remove /s regex modifier (your files are UTF8 anyway
  • Remove rcov
  • In Rakefile, replace require 'rake/rdoctask' with require 'rdoc/task'

Error: wrong number of arguments (given 1, expected 0)
: Use procs instead of lambdas where they are called with variable arguments. Look for named_scopes.

Error: Attempt to call private method, NoMethodError
: Fix tests by replacing thing.private_method with thing.send :private_method

will_paginate errors
: If you get pagination errors, make sure a collection isn't silently replaced after pagination:

# does not work
@contracts = @contracts.reject {...}

# works
@contracts.reject! {...}

YAML fixes

  • Change

    # old 
    date:
      order: [ :day, :month, :year ]
    
    # new
    date:
      order:
        - :year
        - :month
        - :day
    

Also see Upgrade from Ruby 1.8.7 to 2.1.5 – an incomplete guide.

Dominik Schöler
Last edit
Dominik Schöler
Keywords
update
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2018-12-21 12:18)