Closed7

RSpec入門・演習1

なななななな

2023.10.16

今日からRSpec編。結構苦労してる人多い感じなのでちょっとドキドキ。

なななななな

まずは環境構築から。
GitHubのリポジトリをフォークしてローカルにclone。

なななななな

次にRSpecのセットアップ。
テストではできたんだけど、下記のメッセージも一緒に出た。なんか対応したほうがいいのかな。

DEPRECATION WARNING: Using legacy connection handling is deprecated. Please set
`legacy_connection_handling` to `false` in your application.

The new connection handling does not support `connection_handlers`
getter and setter.

Read more about how to migrate at: https://guides.rubyonrails.org/active_record_multiple_databases.html#migrate-to-the-new-connection-handling
 (called from <top (required)> at /sample_app_for_rspec/config/environment.rb:5)
DEPRECATION WARNING: Non-URL-safe CSRF tokens are deprecated. Use 6.1 defaults or above. (called from <top (required)> at /sample_app_for_rspec/config/environment.rb:5)
DEPRECATION WARNING: Using legacy connection handling is deprecated. Please set
`legacy_connection_handling` to `false` in your application.

The new connection handling does not support `connection_handlers`
getter and setter.

Read more about how to migrate at: https://guides.rubyonrails.org/active_record_multiple_databases.html#migrate-to-the-new-connection-handling
 (called from <main> at /sample_app_for_rspec/config/environment.rb:5)
DEPRECATION WARNING: Non-URL-safe CSRF tokens are deprecated. Use 6.1 defaults or above. (called from <main> at /sample_app_for_rspec/config/environment.rb:5)
なななななな

ロボらんてくんに訊いてみたところ、Railsのデータベース接続の扱い方が変わったことに関する警告とのこと。以前使われていたconnection_handlersというものが非推奨になり新しい接続の扱い方が導入されたため、アプリの設定でlegacy_connection_handlingをfalseにするよう推奨している。ただしあたらしい方ではconnection_handlersのgetterおよびsetterというメソッドが使えなくなっているので、もし使っている場合はコード修正が必要になる。…ということらしい。
RSpecについて詳しいことがまだわかっていないので、とりあえず何もせずこのまま進めることにする。

なななななな

ということでここまでの変更をコミットしてプッシュする。コミットメッセージは「RSpecのインストールとセットアップ」にしよう。

なななななな

プルリクエスト作成OK。
最後にプルリクのマージをして完了か。

なななななな

ここからの課題は、

  1. ブランチ切る
  2. コミット&プッシュ
  3. GitHub上でプルリクエスト作成(自分のリポジトリのdevelop←作業ブランチ)
  4. プルリクエストのマージ
  5. ローカルでブランチをdevelopに切り替えてgit pull origin developで最新の状態に

の流れで進めていく。わからなくなったらChapter1を見なおす、と。

このスクラップは2023/10/16にクローズされました