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 3 years have passed since last update.

Rspecのセットアップ

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

Gemを記述できたらbundle install

% bundle install

サーバー再起動

% rails s

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

% rails g rspec:install

テストコードの結果をターミナル上で可視化するため、
.rspecに以下の記述をしましょう。

.rspec
--require spec_helper
# 以下を記述
--format documentation

この記述をすることによってテスト実行時のログがより詳細に表示される。

エラーメッセージを英語に設定

spec/rails_helper.rb
# 中略
I18n.locale = "en"
# RSpec.configure do |config| 〜 end の外に記載

RSpec.configure do |config|

# 中略

end
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?