factory-bot Questions

2

I have: RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods end which properly work with simple rspec spec/model/user_spec.rb (allows me to use create(:user), not FactoryGir...
Cheesewood asked 13/3, 2013 at 8:59

1

Solved

I have got a class, that is the base of some other classes that specializes the behavior: class Task < ActiveRecord::Base attr_accessible :type, :name, :command validates_presence_of :type, :...
Ruggles asked 20/8, 2013 at 9:53

3

Solved

I'm trying to configure FactoryGirl to work with my Cucumber tests. I added the following lines in env.rb require 'factory_girl' Dir.glob(File.join(File.dirname(__FILE__), '../../spec/factories/*....
Omphalos asked 23/12, 2010 at 11:12

1

I've got two traits in my factory, and I want one of them to be included when I create the object, without it defaulting to one (so randomly pick the trait). Here's what I'm doing: FactoryGirl.def...
Evitaevitable asked 22/5, 2013 at 17:43

1

From my understanding, the return value from a factory's 'to_create' method is ignored. This means that the object returned from the 'build' or 'initialize_with' portion of the factory is the objec...
Lush asked 1/9, 2013 at 2:38

1

Solved

Before(:all) do puts "HELLO ALL :D" end I have some problem with my code: /spec/factories.rb require 'faker' FactoryGirl.define do factory :booking_error do booking_id { Faker::Number.numb...
Cook asked 3/9, 2013 at 14:53

3

I recently upgraded an app to rails 3.2.2. I'm using Factory_girl Factory.sequence :name do |n| "name-#{n}" end Factory.define :user do |u| u.first_name{ Factory.next(:name) } u.last_name {...
Bred asked 3/3, 2012 at 7:26

2

Solved

Let’s say you have the following mongoid documents: class User include Mongoid::Document embeds_one :name end class UserName include Mongoid::Document field :first field :last_initial embe...
Porkpie asked 24/9, 2011 at 0:16

2

Solved

I want to pass a parameter into a factory that will be used to set the attribute on an associated model. The associated model is created within the factory. I have a Transaction model with a many-...
Talmud asked 3/5, 2012 at 15:29

2

Solved

How can i create a fixture for ActsAsTaggableOn::tag Using FactoryGirl ? I tried : /spec/factories/tags.rb Factory.define ActsAsTaggableOn::Tag do |f| f.sequence(:name) { |n| "titre#{n}" } end ...
Nilla asked 3/3, 2012 at 9:27

5

Solved

I'm trying to use factory_girl to create a "user" factory (with RSpec) however it doesn't seem to be operating transactionally and is apparently failing because of remnant data from previous tests ...
Liverish asked 16/8, 2010 at 20:40

1

Solved

By default, FactoryGirl calls the factories of associations to create them. I can pass a association for a factory as a parameter. But how can I passa an object which should be used deep in the ass...
Graphy asked 10/7, 2013 at 13:18

4

Solved

These are 2 simple models: class Post < ActiveRecord::Base has_one :asset, :dependent => :destroy validates :asset, presence: true end class Asset < ActiveRecord::Base belongs_to :po...
Susquehanna asked 10/6, 2013 at 23:29

4

Solved

ruby-1.9.2-p180 :007 > Factory.define :user do |user| ruby-1.9.2-p180 :008 > user.email "[email protected]" ruby-1.9.2-p180 :009?> user.password "foobar" ruby-1.9.2-p180 :010?> use...
Doran asked 8/4, 2011 at 13:7

3

It doesn't really seem like factory_girl receives much attention these days. Is there a better alternative? I really like FG, but I need to know that they'll keep working on it. Particularly the s...
Twicetold asked 23/5, 2011 at 21:10

3

Solved

FactoryGirl won't set my protected attribute user.confirmed. What's the best practice here? Factory.define :user do |f| f.name "Tim" # attr_accessible -- this works f.confirmed true # attr_prote...

1

Solved

I'm writing some tests that call a FG create with a trait that after_create, makes an associated object. Is there a way to send parameters to that associated product when I make the FG, or do I nee...
Challah asked 5/3, 2013 at 19:0

2

Solved

I have (simplified) factories defined as follows: factory :league do acronym 'NBA' end factory :division do league end Divisions belong to Leagues. When I define this factory, it was my assum...
Expeller asked 24/5, 2013 at 1:52

1

Solved

I am trying to test my application with cucumber and capybara. I have the following step definition: Given(/^I fill in the create article form with the valid article data$/) do @article_attribute...
Red asked 11/5, 2013 at 21:56

2

Does anyone know how to reset the sequence method for FactoryGirl? I have a factory that creates a list of tasks and I want to order to start at 1 every time. I use 'sequence' because the task lis...
Severson asked 28/7, 2012 at 0:36

7

This has been causing some frustration recently... It seems that using Factories in my cucumber tests, in some situations causes AssociationTypeMismatch errors such as: MyModel(#65776650) expect...
Scullery asked 28/2, 2011 at 17:13

3

Solved

I think there is a problem with my user factory being built. I'm getting an error saying that the password cannot be blank, but it's clearly set in my factories.rb. Does anyone see anything that I ...
Eggcup asked 17/5, 2011 at 14:14

4

Solved

Working with RSpec & Capybara, I'm getting an interesting test failure mode which goes away with a few subtle rearrangements of lines in the test case...stuff that shouldn't matter. I'm develo...
Grommet asked 12/8, 2011 at 0:29

1

Solved

Here is an example from the FactoryGirl documentation: FactoryGirl.define do factory :post do name "Post name" user end end In this example, user is invoking another factory. What I would li...
Bicyclic asked 14/4, 2013 at 13:35

3

Solved

For the life of me, I can't get factory_girl to work in Rails3. I created a brand new application. My Gemfile: gem "rspec" gem "rspec-rails" gem "factory_girl_rails" The generators in applicatio...
Scone asked 23/12, 2010 at 21:8

© 2022 - 2024 — McMap. All rights reserved.