factory-bot Questions
6
Solved
I've got these 5 models: Guardian, Student, Relationship, RelationshipType and School. Between them, I've got these associations
class Guardian < ActiveRecord::Base
belongs_to :school
has_man...
Roberson asked 11/1, 2012 at 13:31
2
I have a user and story models which both of them have comments.
I declared the following models as below:
class Comment
belongs_to :commentable, polymorphic: true
belongs_to :user
end
class U...
Honewort asked 7/8, 2012 at 16:3
1
Solved
I'm using FactoryBot with Rspec on rails.
I have a SpecificKeyword ruby class where I extend the inittialize method:
def initialize(args)
super(args)
# Init regexp field immediatly when creatin...
Dressler asked 10/1, 2018 at 11:14
3
Solved
I'm following this tutorial to get started with TDD on rails with factory girl, rspec and i ran into this issue i can't get my head around.
Here's my "factory".rb (events.rb)
require 'faker'
Fa...
Unguinous asked 11/9, 2012 at 21:59
3
I have a model which has a field called category_paths. It is JSONB in postgres.
When I set the category_paths from factory_girl, factory_girl is changing the value type to String. Consider the f...
Fray asked 8/9, 2015 at 14:1
2
Solved
I'm just wondering whether it's possible to create an attribute called "alias" using FactoryGirl, since alias is a reserved word in Ruby.
FactoryGirl.define do
factory :blah do
name "dummy"
ali...
Orientalize asked 16/2, 2012 at 10:46
2
Solved
Following along with Ben Walker's (amazing) Let's Build Instagram With Rails, specifically the BDD version. Tutorial uses FactoryGirl. I'm getting the following error with a number of tests:
Short...
Cardiogram asked 23/8, 2015 at 22:54
2
Solved
I have some specs, written in RSpec, that test various models. I use Factory Girl to generate object for testing.
Now the most peculiar thing happens:
When i run rspec spec/models/specific_model_s...
Physique asked 4/12, 2011 at 16:10
3
Solved
I'm using Factory Girl to populate my seed data and adding it to the db in seed.rb.
I'm then running my tests using Cucumber.
I have a price table that contains seed data that I want in all my en...
Alexandro asked 22/1, 2011 at 14:24
10
Solved
I'm trying to create a spec for a sign out flow by using factorygirl to create a user and then use Devise's sign_in method to authenticate the user, then use capybara to click the "Sign Out" link.
...
Nolitta asked 4/12, 2014 at 1:17
3
Solved
I love Faker, I use it in my seeds.rb all the time to populate my dev environment with real-ish looking data.
I've also just started using Factory Girl which also saves a lot of time - but when i ...
Mortonmortuary asked 23/1, 2016 at 11:35
1
Solved
Let's say I have the following ActiveRecord models:
class Car
belongs_to :driver
end
class Driver
# Has attribute :name
has_one :car
end
And I define a couple of factories using these models...
Firewarden asked 22/8, 2017 at 17:25
4
There seems to be few resources about the fabrication gem, and I couldn't find a good comparison of the features that distinguish it from factory_girl. As of versions fabrication-2.2.3 and factory_...
Loydloydie asked 29/8, 2012 at 13:29
2
Solved
I have an app where a user can sign in with multiple services, e.g. Google Plus, Facebook, Twitter, etc.
To facilitate this, I have a base User model which has_many Identity records.
Each Ident...
Stigmatic asked 9/4, 2016 at 18:42
6
I am following Michal Hartls Rails tutorial Chapter 7. I have installed the Factory girl gem. I keep getting this error when I run my test
Failures:
1) UsersController GET 'show' should be succe...
Arose asked 2/5, 2012 at 4:51
5
Solved
I have a feature spec with Capybara for a login page, and I am using FactoryGirl + DatabaseCleaner
require 'rails_helper'
feature 'Admin signs in' do
background do
FactoryGirl.create(:user)
e...
Halflight asked 6/4, 2015 at 7:3
7
Solved
I have a Code model factory like this:
Factory.define :code do |f|
f.value "code"
f.association :code_type
f.association(:codeable, :factory => :portfolio)
end
But when I test my controlle...
Iowa asked 24/2, 2011 at 10:48
2
Solved
There is the following factory:
factory :car do
name 'Some car'
engine_value 1.6
color '#ff0000'
car_type
engine_type
transmission
drive_type
material
end
As you see there are a lot of a...
Campbellite asked 4/3, 2014 at 11:31
2
Solved
I've been trying now for hours to get factorygirl to create two factories - one for users, one for organizations.
But I don't seem to understand how I can reflect a 'has_and_belongs_to_many' relat...
Drida asked 8/2, 2014 at 20:12
2
Solved
I'm trying to run rspec with FactoryGirl, but I keep getting this error:
1) Products Update with invalid information
Failure/Error: let(:product) { FactoryGirl.create(:product) }
ArgumentError:
...
Cliffordclift asked 25/5, 2014 at 0:38
6
Solved
The design
I have a User model that belongs to a profile through a polymorphic association. The reason I chose this design can be found here. To summarize, there are many users of the application ...
Nannie asked 12/10, 2011 at 23:56
6
Solved
I'm using scaffolding to generate rspec controller tests. By default, it creates the test as:
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
describe "PUT up...
Norvan asked 10/7, 2014 at 17:21
5
Solved
My problem seems very common, but I haven't found any answer in the documentation or the internet itself.
It might seem a clone of this question has_many while respecting build strategy in factory...
Yell asked 9/11, 2012 at 13:13
2
Solved
I am try to build a json using a factory, but when i try to build it's empty.
Below is Factory class.
require 'faker'
FactoryGirl.define do
factory :account do |f|
f.name {Faker::Name.name}
...
Kadi asked 8/8, 2014 at 14:12
1
I have an Event model that, when saved, updates some attributes on the parent User.
class User
has_many :events
end
class Event
belongs_to :user
before_save :update_user_attributes
validates...
Woodhouse asked 4/4, 2017 at 10:20
© 2022 - 2024 — McMap. All rights reserved.