LoginSignup
0
0

More than 3 years have passed since last update.

RSpecの導入方法

Posted at

概要

どのよう手順でRSpecを導入するのか。忘れてしまう場面が度々ありましたのでここに記述します。

RSpecの導入手順

1.Gemfileに「development, :test」内に「gem 'rspec-rails', '~> 4.0.0'」を記述する。

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails', '~> 4.0.0'
end

2.ターミナルで「bundle install」を記述

3.ターミナルで「rails g rspec:install」を記述

4. .rspec内に「--format documentation」を記述する。(ターミナル上でテストコードの結果を可視化するため)

ruby.rspec
--require spec_helper
--format documentation

5. ターミナルでテストコード用のモデルを作成する。

rails g rspec:model モデル名

以上の手順でRSpecの導入を行うことが出来る。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0