LoginSignup
5
5

More than 5 years have passed since last update.

Rails 4.2にアップデートすると、"ArgumentError: wrong number of arguments (2 for 1)"というエラーが出てテストが失敗する場合

Posted at

問題

既存のRailsプロジェクトを4.2にアップデートして、RSpec等のテストを実行すると、以下のようなエラーが出てフィーチャスペックやコントローラスペックが失敗する場合があります。

ArgumentError: wrong number of arguments (2 for 1)
./app/controllers/contacts_controller.rb:39:in `block (2 levels) in create'
./app/controllers/contacts_controller.rb:37:in `create'
./spec/controllers/contacts_controller_spec.rb:125:in `block (6 levels) in <top (required)>'
./spec/controllers/contacts_controller_spec.rb:124:in `block (5 levels) in <top (required)>'
./spec/rails_helper.rb:40:in `block (3 levels) in <top (required)>'
./spec/rails_helper.rb:39:in `block (2 levels) in <top (required)>'
-e:1:in `<main>'

原因

Turbolinksのバージョンが古いとこのエラーが起きるようです。

最低でも2.2.3以上に上げる必要があるみたいです。

解決策

Turbolinksをアップデートしましょう。

bundle update turbolinks

同じような問題に遭遇した人は参考にしてみてください。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5