factory_bot is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
Used 22 times
E
Emanuele Bonanno
Usage
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/X8BsZv"
Template Source
Review the code before running this template on your machine.
inject_into_file 'Gemfile', after: 'group :development, :test do' do
<<-RUBY
gem "factory_bot_rails"
RUBY
end
after_bundle do
file 'spec/support/factory_bot.rb', <<~CODE
require "factory_bot_rails"
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end
CODE
end