Rails Gem Upgrading Tips and Strategies - Rails on Maui

Here’s an example of where updating related gems help.

bundle update capybara fixed the following error

--------------------------------------------------------------------------------
Capybara::RSpecMatchers::HaveText implements a legacy RSpec matcher
protocol. For the current protocol you should expose the failure messages
via the `failure_message` and `failure_message_when_negated` methods.
--------------------------------------------------------------------------------

The final error I got was this one, from cancan.

Deprecation Warnings:
`failure_message_for_should_not` is deprecated. Use `failure_message_when_negated` instead. Called from /Users/justin/.rvm/gems/ruby-2.1.2@bpos/gems/cancan-1.6.10/lib/cancan/matchers.rb:11:in `block in <top (required)>'.
`failure_message_for_should` is deprecated. Use `failure_message` instead. Called from /Users/justin/.rvm/gems/ruby-2.1.2@bpos/gems/cancan-1.6.10/lib/cancan/matchers.rb:7:in `block in <top (required)>'.

A quick google search reveals that cancancan fixes the issue:

Once I got all tests passing, I tried to update to Rails 4.1, but ran into this issue:

bundle update rails                                                                                                                                                                                             ✹ ✭ [20:31:38]
Fetching source index from https://rubygems.org/
Resolving dependencies........................
Bundler could not find compatible versions for gem "activemodel":
  In Gemfile:
    simple_form (>= 0) ruby depends on
      activemodel (< 4.1, >= 4.0.0) ruby
    rails (~> 4.1) ruby depends on
      activemodel (4.1.0)

I verify I’m on the current maximum GA version of simple_form, but I find that there’s an RC version, so I specify that in the gemfile. It’s important to note that “bundle update” will tend not to pull in RC versions of gems, which you sometimes need after major libraries are upgraded.

In Gemfile

1 2 gem 'rails', '~> 4.1' gem 'simple_form', '>= 3.1.0.rc2'
> bundle update rails simple_form
Using rails 4.1.4 (was 4.0.8)
Installing simple_form 3.1.0.rc2 (was 3.0.1)
Your bundle is updated!

After the 4.1 upgrade, I addressed a number of deprecation warnings.

DEPRECATION WARNING: Implicit join references were removed with Rails 4.1.Make sure to remove this configuration because it does nothing. (called from block in tsort_each at /Users/justin/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226)
1 config.active_record.disable_implicit_join_references = true

Then I got this warning with a full stack dump.

Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
  /Users/justin/.rvm/gems/ruby-2.1.2@bpos/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'

The stack dump was useless, but the search for error message on Google found this indicating that the issue had something to do with shoulda-matchers. A check of my gem version revealed that my gem version was not current.

> bundle update shoulda-matchers
Installing shoulda-matchers 2.6.2 (was 2.5.0)

And that fixed that issue!

Thanks to Mike Perham, Ed Roman, Ben Ward, and Greg Lazarev for reviewing drafts of this article.

Please let me know if this article helped you or if I missed anything!

Aloha,

Justin


This is a companion discussion topic for the original entry at http://www.railsonmaui.com//blog/2014/09/14/upgrading-to-rails-4-and-rspec-3-with-capybara-and-resque/