LoginSignup
8
4

More than 3 years have passed since last update.

Railsコマンドが正常に操作しない時疑うべきはspring

Posted at

動機

Railsを用いてテストコードを作成中に以下のコマンドを打つと正常に動作しなくなったので備忘録としてどのように解決したかを記述

$ rails g rspec:request article


Running via Spring preloader in process 15349
Deprecation warning: Expected boolean default value for '--orm'; got :active_record (string).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
Could not find generator 'rspec:request'. Maybe you meant "rspec:decorator"?
Run `rails generate --help` for more options.

springとは?

ザックリですが
「開発をよりスピードアップさせるため開発しているアプリケーションをバックグラウンドで保持し、「テスト・rakeタスク・マイグレーション」を毎回起動しなくてもいいようにしてくれるRailsアプリケーションのプリローダー」

といいやつに見えて、ここのプロセスが残っていたりするのが問題の可能性があります。

解決手順

まずはspringのstatusを確認

$ spring status


Spring is running:

 3729 spring server | blogapp | started 17 hours ago

やはり止まっていました。

次にspringの停止を行います。

$ spring stop
Spring stopped.

再度状態確認

$ spring status
Spring is not running.

再度Railsコマンド実行

$ rails g rspec:request article
Running via Spring preloader in process 15565
      create  spec/requests/articles_spec.rb

成功しました!

再度コマンド操作を行うとspringも実行されますのでご心配なく

身に覚えの無いエラーが起きた際はspringを疑ってみましょう

8
4
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
8
4