factory-bot Questions

3

Solved

I've got a problem with Spork test server. If I set config.cache_classes = false in config/environments/test.rb then specs start to rasie errors. Failure/Error: task = Factory(:something, :foo =...
Functional asked 6/5, 2011 at 15:1

2

Solved

There aren't currently any up to date answers for this using Factory Girl 4.1 (that I could find) - how do you setup a many to many relationship inside of a factory? For instance I have Students a...
Chretien asked 4/1, 2013 at 17:58

2

I have an Invoice model that may contain a number of Items as well: class Invoice < ActiveRecord::Base attr_accessible :number, :date, :recipient, :items_attributes belongs_to :user has_m...
Paniculate asked 4/3, 2013 at 13:48

2

Solved

I have the following rspec test that works: it "redirects to the created api_key" do post :create, :api_key => {:api_identifier => "asdfadsf", :verification_code => "12345"} response....
Refinery asked 26/2, 2013 at 15:57

1

Solved

I have a simple situation setup in order to learn testing with FactoryGirl. A Bank has many transactions. Each time a transaction is created, it should subtract the transaction amount from the bank...
Selfridge asked 22/2, 2013 at 2:50

1

Solved

I'm trying to defined a has_many relationship in FactoryGirl using the after_create callback, like so in /spec/factories/emails.rb: FactoryGirl.define do factory :email do after_create do |email...
Billi asked 21/2, 2013 at 13:51

4

Solved

I am doing TDD/BDD in Ruby on Rails 3 with Rspec (2.11.0) and FactoryGirl (4.0.0). I have a factory for a Category model: FactoryGirl.define "Category" do factory :category do name "Foo" end e...
Horal asked 14/9, 2012 at 11:6

4

Solved

I'm trying to solidify my understanding of rails and the BDD workflow, so I wanted to start small by creating one of those mini-blogs, but with rspec. Right now I have an ArticlesController and Art...
Bahia asked 10/2, 2012 at 5:51

2

Hello i need to build up Factory for my model, for example Factory.define :farm do |f| f.name { Factory.next :name } f.harvest '3' f.offers 'Random' f.latitude '43' f.longitude '-70' f...
Mose asked 13/5, 2011 at 10:51

1

Solved

I keep getting this error when I run rspec: Sequence not registered: email. However, I did set it in my factories.rb file. Any ideas on how to fix this? The app is running fine. Failures: 1) U...
Jetport asked 21/1, 2013 at 7:12

2

Solved

I have a factory such as: FactoryGirl.define do factory :page do title 'Fake Title For Page' end end And a test: describe "LandingPages" do it "should load the landing page with the correct...
Terraterrace asked 18/1, 2013 at 0:0

4

Solved

I'm trying to use Cucumber and Factory Girl. The following lines: Given I am not logged in And the following user exists: | login | email | password | confirmation | | user50 | [email pro...
Roofdeck asked 18/5, 2011 at 13:39

1

Solved

UPDATE I went back to using Fixtures. IMOP, fixtures are FAR better than factories; easier to use, easier to write, easier to understand (no magic). My suggestion: limit your testing library to th...
Selfcentered asked 30/12, 2012 at 3:8

1

Solved

I am pretty sure I am missing something really basic here. I want to test if a before_save callback does what it is supposed to do, not just that it is called. I wrote the following test: it 'sh...
Chromoprotein asked 31/1, 2012 at 23:3

1

Solved

I have an account model that belongs_to a role model. factory :role do name "student" end factory :account do user role end The first factory creates a role named "student". The second facto...
Classis asked 30/12, 2012 at 18:19

3

Solved

What's the purpose of factories/fixtures (I know factories act like fixtures, but a bit clearer) when you can simply use ActiveRecord in your test to create the database entry? i.e. News.create(…) ...
Maisonette asked 14/4, 2012 at 16:17

1

Solved

I have been fighting with my associations for 3 solid days and don't know where else to turn. I'm sure the problem is very simple, but I'm fairly new to Ruby on Rails and this has me stumped... I'...
Proficiency asked 21/12, 2012 at 23:11

1

I am trying to use paperclip with factory_girl gem but getting a "no handler found error" message. test_should_update_category(CategoriesControllerTest): Paperclip::AdapterRegistry::NoHandlerEr...
Genus asked 29/11, 2012 at 14:26

1

Solved

I am trying to create my first controller test using FactoryGirl for my Rails application, but I keep retrieving the following error: uninitialized constant FactoryGirl My Factories.rb file look...
Lauds asked 8/12, 2012 at 20:14

1

Solved

I am pretty new to factory_girl and I have the following problem. I have a class say of the form: class Fruit::Apple < ActiveRecord::Base ... end Suppose I need to create factories for this...
Rayon asked 27/11, 2012 at 18:20

1

Solved

I'm building a setup screen for billing of individuals. The controller/views are in the Admin namespace. When run the first test without :js => true I get one failure, which I assume is down to th...
Sebastian asked 25/10, 2012 at 15:18

1

Solved

I have the following in /app/models: class Area < ActiveRecord::Base has_many :locations end class Location < ActiveRecord::Base belongs_to :area end in /app/test/factories/areas.rb Fa...
Centi asked 1/11, 2012 at 15:16

1

Solved

Looking through a tutorial on controller testing the author gives an example of an rspec test testing a controller action. My question is, why did they use the method attributes_for over build? The...
Dartboard asked 31/10, 2012 at 2:4

1

Solved

Seems simple, but haven't been able to figure out how to get this to work. In model.rb: def Model attr_accessor :width, :height def initialize params @width = params[:width] @height = param...
Addlebrained asked 18/10, 2012 at 16:11

3

Fixed. There was a bug in Rails. See https://github.com/rails/rails/issues/2333 I have a problem with Factory Girl Rails and Rails 3.1.0.rc5 When I do more than once user = FactoryGirl.create(:us...
Rescue asked 2/8, 2011 at 13:53

© 2022 - 2024 — McMap. All rights reserved.