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.

Using factory_girl_rails with Rspec on namespaced models

I have a web service that serves Ads to several different clients. The structure of the Ad varies between clients, …

ruby-on-rails-3 namespaces rspec factory-bot
Why isn't factory_girl operating transactionally for me? - rows remain in database after tests

I'm trying to use factory_girl to create a "user" factory (with RSpec) however it doesn't seem to be operating …

ruby-on-rails factory-bot
Why do I get an undefined method 'have' error when running Rspec?

I recently upgraded to Rails 4 and everything works fine except for my Rspec tests. require 'spec_helper' describe Invoice do …

ruby-on-rails rspec ruby-on-rails-4 factory-bot
Factory Girl + Mongoid embedded documents in fixtures

Let’s say you have the following mongoid documents: class User include Mongoid::Document embeds_one :name end class UserName …

ruby-on-rails embed mongoid factory-bot fixtures
How to add "config.include FactoryBot::Syntax::Methods" to rspec config block in spec_helper.rb?

If I add: config.include FactoryBot::Syntax::Methods under RSpec.configure do |config| and run rspec, I see this error: /…

ruby-on-rails rspec factory-bot rspec-rails
how to define factories with a inheritance user model

I got following problem: In my application i use inheritance to define my user model: class User include Mongoid::Document …

ruby-on-rails ruby-on-rails-3 factory-bot
Testing simple STI with FactoryGirl

I have got a class, that is the base of some other classes that specializes the behavior: class Task < …

ruby-on-rails ruby rspec factory-bot sti
FactoryGirl, has_one association and validation failed

These are 2 simple models: class Post < ActiveRecord::Base has_one :asset, :dependent => :destroy validates :asset, presence: true end …

ruby-on-rails rspec factory-bot
How to user factory girl to create associated lists with a has_many with a validation that requires it on create

In a Rails application, given three models User, Article and Reviewer with the following relationships and validations: class User < …

ruby-on-rails-3 factory-bot
How to specify the association with factory_bot?

For example I have two models a user and a post. A post belongs_to a user and a user …

ruby-on-rails ruby rspec factory-bot