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。
最後にプルリクのマージをして完了か。
ここからの課題は、
- ブランチ切る
- コミット&プッシュ
- GitHub上でプルリクエスト作成(自分のリポジトリのdevelop←作業ブランチ)
- プルリクエストのマージ
- ローカルでブランチをdevelopに切り替えて
git pull origin develop
で最新の状態に
の流れで進めていく。わからなくなったらChapter1を見なおす、と。
このスクラップは2023/10/16にクローズされました