はじめに
今回はeverudayrailsの2章(Rspecのセットアップ)が終了している状態のものから始めることにする。
開発環境
Mac os 11.2.3
ruby 2.7.1
シェル zsh
git clone
適当なディレクトリで
git clone https://github.com/JunichiIto/everydayrails-rspec-2017.git
これですでにリポジトリがoriginに登録されていてmasterブランチにいるので
リモートブランチを以下のように自分のブランチに持ってくる。
git checkout -b my-03-models origin/02-setup
これで始めたい章のソースコードになっている。
続いてrails 6に対応させる。
まずはGemfile.lockの一番下のBUNDLED WITHを変更する。おそらく1.14.4くらいのバージョンになっているので新しいバージョンに書き換える(事前に新しいバージョンのbundlerのインストールが必要。)
BUNDLED WITH
2.1.4
とする。
次にGemfileのrails,rspec-railsのみをを編集
gem 'rails', '~> 6.1', '>= 6.1.3.1'
gem 'rspec-rails', '~> 5.0'
この状態で
bundle update
を行うとおそらく下記エラーが出る
An error occurred while installing mimemagic (0.3.10), and Bundler cannot continue.
Make sure that `gem install mimemagic -v '0.3.10' --source 'https://rubygems.org/'` succeeds before bundling.
これを解消するために下記を実行
brew install shared-mime-info
次に
bundle update
次に下記を順に実行
rails db:create
rails db:migrate
rails s