0
0

More than 1 year has passed since last update.

RSpec(Ruby on Railsのテストコードを書くために用いられるGem)の導入

Last updated at Posted at 2022-10-13

はじめに

RSpec導入の流れを忘れないために記録に残す。

RSpec導入の流れ

1.Gemの導入

# 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', '~> 4.0.0'  ⇦この行を追記
end

% bundle install

2.RSpecの設定

% rails g rspec:install
   
<ターミナルで以下が表示されれば問題ない>
create  .rspec
create  spec
create  spec/spec_helper.rb
create  spec/rails_helper.rb



# .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