LoginSignup
1
0

More than 5 years have passed since last update.

Rails4からRails5へのテストケースでキーワード引数を機械的に一括変換する。

Posted at

Rails5からテストケースにてHTTP methodsで利用する場合、キーワード引数が必須になった。

before

post url, hoge: 'foo'

after

post url, params: { hoge: 'foo' }

Rails4からRails5へ以降する際に、既存のspecファイルが大量にある場合、手動で行うとなかなか以降がスムーズに行きづらいです。

機械的に一括変換をする。

機械的に一括変換をするgemがあります。

spec/controller/test_controller.rb
  get :index
      search: 'bayleef',
      format: :json
Gemfile
+ gem 'rails5-spec-converter'
$ bundle install --path vendor/bundle
$ bundle exec rails5-spec-converter
spec/controller/test_controller.rb
  get :index
      params: {
        search: 'bayleef'
      },
      format: :json
1
0
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
1
0