sajad torkamani

Install gem

Add to Gemfile:

group :development, :test do
  gem 'factory_bot_rails'
end

Run:

./bin/bundle install

Configure with RSpec

Create spec/support/factory_bot.rb:

# frozen_string_literal: true

RSpec.configure do |config|
  config.include FactoryBot::Syntax::Methods
end

Make sure this file is included from your rails_helper.rb or spec_helper.rb.

Sources

Leave a comment

Your email address will not be published. Required fields are marked *