Top "Factory-bot" questions

factory_bot is a Ruby gem that allows you to quickly define prototypes for each of your models and ask for instances with properties that are important to the test at hand.

Populating an association with children in factory_girl

I have a model Foo that has_many 'Bar'. I have a factory_girl factory for each of these objects. …

ruby-on-rails ruby unit-testing factory factory-bot
What is the purpose of a `transient do` block in FactoryBot factories?

What is the purpose of transient do in FactoryBot factories? I've seen a lot of factories that begin with something …

ruby-on-rails ruby rspec factory-bot
Factory not registered: user

I am following Michal Hartls Rails tutorial Chapter 7. I have installed the Factory girl gem. I keep getting this error …

ruby-on-rails ruby factory-bot
FactoryGirl: Factory not registered: user (ArgumentError)

Having a lot trouble getting all the ducks in the right order with FactoryGirl. Set up a minimalist rails app (3.0.11), …

ruby cucumber factory-bot
Upgrading to devise 3.1 => getting Reset password token is invalid

Solution Thanks to this gist form Steven Harman, I got it working. devise_mail_helpers.rb module Features module MailHelpers …

ruby-on-rails devise ruby-on-rails-4 factory-bot rspec2
Pass parameter in setting attribute on association in FactoryGirl

I want to pass a parameter into a factory that will be used to set the attribute on an associated …

ruby-on-rails ruby-on-rails-3 rspec factory-bot
Clearing the test database between unit and functional tests in Rails (factory_girl)

Recently I switched from fixtures to factory_girl to test my Ruby on Rails application. If I run rake test:…

ruby-on-rails ruby unit-testing factory-bot
FactoryGirl build_stubbed strategy with a has_many association

Given a standard has_many relationship between two objects. For a simple example, let's go with: class Order < ActiveRecord::…

ruby-on-rails factory-bot
when does factory girl create objects in db?

I am trying to simulate a session using FactoryGirl/shoulda (it worked with fixtures but i am having problems with …

ruby-on-rails shoulda factory-bot