毎回忘れるのでメモ
準備
RSpec
を入れておく
Gem
group :development, :test do gem 'factory_girl_rails' end
$ bundle install
spec/rails_helper.rb
RSpec.configure do |config| 〜〜 # 下記1行追加 config.include FactoryGirl::Syntax::Methods end
config/application.rb
class Application < Rails::Application 〜〜 # 下記ブロック追加 config.generators do |g| g.test_framework :rspec, fixtures: true, view_specs: false, helper_specs: false, routing_specs: false, controller_specs: true, request_specs: false g.fixture_replacement :factory_girl, dir: "spec/factories" end end