【Rails】RSpec初期設定方法
RSpecの初期設定
テスティングフレームワークRSpecのインストール、初期設定の方法
Gemfileの中 「gem 'rspec~~~~~' 」で始まるコードを追加します。
./Gemfile
group :test do # Adds support for Capybara system testing and selenium driver # gem 'capybara', '>= 2.15' # gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome # gem 'chromedriver-helper' gem 'rspec-rails', '~> 3.7' end
次にターミナルで以下のように「bundle install」を実行します。
$ bundle install
次に以下のコードでRSpecに必要なディレクトリやファイルを作成します。
$ rails g rspec:install
インストール完了後
specディレクトリの中に以下のファイルが追加してあればインストール、初期設定の完了です。
spec/spec_helper.rb spec/rails_helper.rb