0
0

RSpecの導入方法(準備まで)

Posted at

環境構築の手順

① Gemの追加

Gemfile
group :development, :test do
  ...
  # 以下追加
  gem 'rspec-rails'
  gem 'factory_bot_rails'
end

② RSpec用の設定ファイルを生成する

bundle exec rails g rspec:install

下記のようにファイルが作成される

 create  .rspec
 create  spec
 create  spec/spec_helper.rb
 create  spec/rails_helper.rb

③ テストを実行してみる

bundle exec rspec 

以下のような結果になれば、RSpecを利用する準備は完了。
テストファイルをまだ作成していないため、このように表示される。

No examples found.

Finished in 0.00026 seconds (files took 0.05634 seconds to load)
0 examples, 0 failures
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