gennei's blog

IT、読書、日記、メモ

Rails Tutorial 9章でテストエラーとなった。解決策つき。

RailsTutorialの9章を進めていてエラーが起きた。

エラー内容

Failures:

1) Authentication authorization for non-signed-in users in the Users Controller submitting to the update action Failure/Error: specify { expect(response).to redirect_to(signin_path) } NoMethodError:undefined method assertions' for #RSpec::Rails::TestUnitAssertionAdapter::AssertionDelegator:0x007fb298809560> # ./spec/requests/authentication_pages_spec.rb:53:inblock (6 levels) in '

回避策

Gemで指定していたRspecのversionが古かった。

修正前

gem 'rails', '4.1.6'
gem 'rspec-rails', '2.13.1'

修正後

gem 'rails', '4.1.6'
gem 'rspec-rails', '2.14.0'

原因

bug らしい
You can no longer `include Minitest::Assertions` · Issue #286 · seattlerb/minitest · GitHub

Stack Over Flowにもテストが通らない人がいた。
rspec2 - Rails 4 and RSpec, undefined method `assertions' in routing spec - Stack Overflow