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導入まで(自分用メモ)

Last updated at Posted at 2020-04-12

gem 'rspec-rails' を記述

gemfile

group :development, :test do
  gem 'rspec-rails'
end

bin/rails g rspec:installでインストール

$ bin/rails g rspec:install

gem 'spring-commands-rspec' を記述(Speingを使いたい場合)

group :development do
  gem 'spring-commands-rspec'
end

bundle exec spring binstub rspec でbinディレクトリ内にrspecの実行用ファイルを作成

$ bundle exec spring binstub rspec

bin/rspecでインストールできている確認

$ bin/rspec

rails g で何かを作成した際に、RSpec用ファイルも作るようにする

config/application.rb
# 省略
module Sample
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 6.0
    
   # ここを記述
    config.generators do |g|
      g.test_framework :rspec,
        fixtures: false,    # fixtureなどのファイルは作らないようにする
        view_specs: false,
        helper_specs: false,
        routing_specs: false
    end
  end
end

参照: https://leanpub.com/everydayrailsrspec-jp

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?