0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rspecの導入

0
Posted at

はじめに

忘れないためにアウトプットさせてもらいます
テストコードのためfactory_botとfakerも導入します

テストで使うGemを導入

Gemfileの中のgroup :development, :test do ~ endとある「do ~ endの間」に記述する

Gemfile
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'
  gem 'factory_bot_rails'
  gem 'faker'
end

1つ目 rspec導入
2つ目 factory_bot導入(毎回インスタンスを生成するのをなくすため)
3つ目 faker導入(ダミーデータを生成するため)

必要なGemが記述できたら、ターミナルへ

ターミナル
% bundle install

Gemを新しくインストールしたのでローカルサーバーを再起動

ターミナル
% rails s

導入したRSpecを使用できるようする

ターミナル
% rails g rspec:install

テスト結果のログを見やすくしテストコードの結果をターミナル上で可視化する

.rspec
--require spec_helper
--format documentation

最後に

簡単なアウトプットでした

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?