アウトプットの部屋

エンジニアになるためのアウトプット

RSpec②~supportファイルの設定~

supportファイルの作成や設定のメモ

1 ファイル作成

mkdir spec/support
touch spec/support/request_helper.rb

2 rails_helper.rbを編集 以下の行をコメントインする

Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }

eachメソッドでsupportディレクトリ配下のファイルを1つずつ読みこむ。

さらにconfigの配下に記入

config.include RequestHelper

これで各ファイルにincludeされるようになる