factory-bot Questions
1
Solved
Hi have this special use case, in which I have to define a factory in one file without a certain parameter, and then insert it in the factory definition later. This is a case where I am importing f...
Sapienza asked 11/10, 2012 at 9:43
2
Solved
I'm working on a Yahoo Answers sort of app to improve my Rails skills.
So far I've set two models "Question" and "Answers" and they are nested this way:
resources :questions do
resources :answer...
Brezin asked 8/7, 2012 at 0:26
1
Solved
Within a factory, how do I refer to the value of one of the other fields in the object being created?
Suppose my model Widget has two fields, nickname and fullname
Inside my factory, I want to us...
Karalee asked 7/10, 2012 at 1:3
3
Solved
My controller spec fails because Factory Girl seems to be creating non-unique Users even though I sequence the User attributes that need to be unique.
The Errors
1) TopicsController POST #create...
Cockleboat asked 22/5, 2011 at 21:51
1
Solved
I am using devise, rolify and cancan. I'm also using RSpec with FactoryBot for testing. Right now I'm working on some tests and I want to define users with different roles for those tests. Here is ...
Katzman asked 12/9, 2012 at 3:55
3
I've been having trouble trying to create factories for some objects and associations that I have defined in my project. I have a cyclic kind of association, where an object is associates with two ...
Gingivitis asked 7/9, 2012 at 15:20
2
Solved
I need to create some factories that are made of multiple has many through's
Here are my models
Topic
has_many :plan_topics
has_many :plans, :through => :plan_topics
PlanTopic
belongs_to :...
Though asked 24/11, 2011 at 15:1
3
Solved
I have 2 models, User and Bucket. User has_many Buckets and a Bucket belongs_to a User.
In factories.rb, I have:
Factory.define :user do |user|
user.email "[email protected]"
user.password...
Cyndy asked 8/4, 2011 at 21:54
2
Solved
I want that when I make changes in factories, I see them in rails console without restarting all console.
I've found some lines and tested them with a poor understanding of what's going on, docume...
Termagant asked 6/9, 2012 at 19:31
2
Solved
I'm designing a test around rails using Cucumber and Rspec and I was wondering if it is good practice sharing the Factory Girl factory code between the Cucumber acceptance test and Rspec unit tests...
Buttonhole asked 16/9, 2011 at 6:38
1
I have a similar error posted here, but all will not fix my problem.
My file 'spec/request/news_controller_spec.rb' looks like:
require 'spec_helper'
describe "NewsController" do
include Devis...
Lichtenfeld asked 25/1, 2012 at 0:13
1
Solved
I've spent the last two hours figuring out what is wrong, but could not find the answer anywhere.
Its my first rails application (except Hartl's tutorial) so the solution might be simple.. I'm usi...
Standup asked 27/8, 2012 at 15:42
1
Solved
Given two models, Alert and Zipcode, where one Alert must have 1 or more Zipcodes:
class Alert < ActiveRecord::Base
attr_accessible :descr, :zipcode
has_many :zipcode
validates :zipcode, :l...
Irisation asked 24/8, 2012 at 23:16
1
Solved
I'm trying to learn how to test with Rspec.
At the moment I have a spec for an Item class:
require 'spec_helper'
describe Item do
it { should belong_to :list }
before(:each) do
@item = Fact...
Grip asked 12/8, 2012 at 15:57
1
Solved
Having trouble getting this done.
I am using seed.rb + factory_girl to populate database with rake db:seed.
(I know that fixtures exists, but I want to get this done this way, this is just an exam...
Calais asked 10/8, 2012 at 14:48
1
Solved
I've been breaking my head on this easy validation and I can't get it to validate. I've got the following model:
class Attendance < ActiveRecord::Base
belongs_to :user, counter_cache: true
be...
Phenomenal asked 3/8, 2012 at 8:15
1
Solved
I have a class that is defined in the module.
module Mod
class Zed
include DataMapper::Resource
end
end
For testing, I define factory.
#/factories/zed.rb
FactoryGirl.define do
factory :zed ...
Disenable asked 27/7, 2012 at 8:23
2
Solved
I'm trying to get FactoryGirl to generate some names for me, but the sequence doesn't seem to increment.
# spec/factories/vessel.rb
require 'factory_girl'
FactoryGirl.define do
sequence :vessel_...
Conservative asked 11/7, 2012 at 21:7
2
Solved
I have a model defined this way
class Lga < ActiveRecord::Base
validates_uniqueness_of :code
validates_presence_of :name
end
I've defined a factory for Lgas with
Factory.sequence(:lga_id)...
Mcdevitt asked 18/3, 2010 at 23:58
2
Solved
I have the following factories:
Factory.define :email do |email|
email.email {"infomcburney.cowan.com"}
end
Factory.define :lead do |lead|
lead.emails {|emails| [emails.association(:email)]}
en...
Yandell asked 28/10, 2010 at 22:58
1
Solved
I'm just curious where people tend to use FactoryGirl.build_stubbed and where they use double when writing RSpec specs. That is, are there best practices like "only use FactoryGirl methods in their...
Lamellar asked 31/5, 2012 at 15:26
1
Solved
In order to debug a factory I've inserted rescue binding.pry at the end of a problematic line:
after_create do |my_object, proxy|
my_object.foreign_key_id = proxy.generated_attribute rescue bindi...
Bloodroot asked 16/4, 2012 at 12:44
2
Solved
In the latest release of FactoryGirl, some syntactic methods such as Factory.create were depreciated in favor of several others, most notably FactoryGirl.create and the simpler create.
However, ex...
Same asked 27/4, 2012 at 22:47
3
Solved
I'm trying to reuse a helper method in all my factories, however I cannot get it to work. Here's my setup:
Helper module (in spec/support/test_helpers.rb)
module Tests
module Helpers
# not guar...
Butler asked 26/10, 2011 at 19:21
3
Solved
This question is an extension to the one raised here:
Using factory_girl in Rails with associations that have unique constraints. Getting duplicate errors
The answer offered has worked perfectly ...
Mcleroy asked 13/3, 2012 at 4:26
© 2022 - 2024 — McMap. All rights reserved.