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.

FactoryBot to build list of objects with trait

I'm using factory_bot to create objects in my test, here is a example of my factory: factory :user do …

ruby factory-bot
How to complete the rspec put controller test from scaffold

I'm using scaffolding to generate rspec controller tests. By default, it creates the test as: let(:valid_attributes) { skip("Add …

ruby-on-rails rspec factory-bot rspec-rails scaffolding
Factory Girl failing Rspec validation tests

I've been trying to get a grasp on writing tests, but having a lot of trouble as the tests never …

ruby-on-rails rspec factory-bot
Extra arguments for Factory Girl

I need to pass extra arguments to factory girl to be used in a callback. Something like this (but more …

ruby-on-rails ruby factory-bot
How can I reset a factory_girl sequence?

Provided that I have a project factory Factory.define :project do |p| p.sequence(:title) { |n| "project #{n} title" } p.…

ruby-on-rails ruby factory-bot
Factory with carrierwave upload field

Hello i need to build up Factory for my model, for example Factory.define :farm do |f| f.name { Factory.…

ruby-on-rails rspec factory-bot carrierwave
FactoryGirl: attributes_for not giving me associated attributes

I have a Code model factory like this: Factory.define :code do |f| f.value "code" f.association :code_type …

ruby-on-rails ruby-on-rails-3 factory-bot
FactoryGirl + Faker - same data being generated for every object in db seed data

I am using FactoryGirl and Faker to generate user objects in my seeds.rb file but for some reason the …

ruby-on-rails database factory-bot seeding faker
factory_girl + rspec doesn't seem to roll back changes after each example

Similar to the problem described here: http://rpheath.com/posts/411-how-to-use-factory-girl-with-rspec in Short (shorten'd code): spec_helper: config.use_transactional_…

ruby-on-rails ruby rspec fixtures factory-bot
Bypass Rails validations when creating FactoryGirl objects

I have two models (ModelA and ModelB), and FactoryGirl factories for each. I want the factory for ModelB to be …

ruby-on-rails factory-bot