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.

How to set up factory in FactoryGirl with has_many association

Can someone tell me if I'm just going about the setup the wrong way? I have the following models that …

rspec ruby-on-rails-3.1 has-many-through factory-bot
ActiveModel::MissingAttributeError: can't write unknown attribute `ad_id' with FactoryGirl

I have the following models: class Ad < ActiveRecord::Base belongs_to :page has_one :image has_one :logo end …

ruby-on-rails factory-bot
Skip callbacks on Factory Girl and Rspec

I'm testing a model with an after create callback that I'd like to run only on some occasions while testing. …

ruby-on-rails rspec factory-bot
How to create has_and_belongs_to_many associations in Factory girl

Given the following class User < ActiveRecord::Base has_and_belongs_to_many :companies end class Company < ActiveRecord::Base …

ruby-on-rails associations has-and-belongs-to-many factory-bot
What's the difference between the build and create methods in FactoryGirl?

The Factory Girl introduction delineates the difference between FactoryGirl.build() and FactoryGirl.create(): # Returns a User instance that's not saved …

ruby factory-bot
FactoryBot: create the same object multiple times

In one of my RSpec test, I am creating multiple objects from the same factory definition Eg FactoryBot.create(:model_1) …

ruby-on-rails rspec factory-bot
How to write an RSpec test for a simple PUT update?

I'm trying to solidify my understanding of rails and the BDD workflow, so I wanted to start small by creating …

ruby-on-rails rspec factory-bot
How do I use factories from FactoryGirl in rails console

I am using rails console in the development environment and I want to use factories. How can I get access …

ruby-on-rails factory-bot
How to define an array / hash in factory_bot?

I am trying to write a test that simulates some return values from Dropbox's REST service that gives me back …

ruby-on-rails-3 rspec factory-bot
How Do I Use Factory Girl To Generate A Paperclip Attachment?

I have model Person that has many Images, where images has a Paperclip attachment field called data, an abbreviated version …

ruby-on-rails paperclip factory-bot