Questions tagged [fabrication-gem]

Fabrication is a fixture replacement library for Ruby.

Fabrication allows you to define schematics for objects and generate valid instances of them on demand in your tests, seeds, or anywhere else. It works with any Ruby object but actively supports ActiveRecord, Mongoid, Sequel, and DataMapper objects.

It is fast, lightweight, and with no gem dependencies at all so you can use it anywhere you want.

69 questions
0
votes
1 answer

How do you DRY up subclassed fabricators?

So I have a parent class with a fabricator, and two subclasses. How do I get the subclasses to reference the parent class's fabricator for setting up shared code? E. G. Fabricator(:parent) do important_variable "Foo" lesser_variable…
RonLugge
  • 5,086
  • 5
  • 33
  • 61
0
votes
1 answer

How to use Fabricate-gem to generate objects?

I'm using Rails 4, Fabricate and Faker Gems. And I'm trying to seed my database with (100 or so) randomly created objects (Order that contains up to 3 Ice Creams). I followed This Answer that recommend using this approach. models/order.rb class…
0
votes
2 answers

Rails Fabrication gem association creating many objects

I have two models with a simple has_many association class Usuario < ActiveRecord::Base has_many :publicaciones, dependent: :destroy end class Publicacion < ActiveRecord::Base belongs_to :usuario, dependent: :destroy validates_presence_of…
1087427
  • 465
  • 5
  • 18
0
votes
1 answer

Rspec 3 and Fabricator - controller spec, unable to create new record

I am trying to solve this without success. I am using RSpec with Faricator and can't get tests pass. The problem appears in create action. Update (with similar syntax) works just fine. From website form everything works correctly so I believe it is…
wbucko
  • 95
  • 1
  • 9
0
votes
1 answer

Factory_girl returning objects and fabricator returning an empty array why?

our test code is currently using factory_girl and I am trying to use fabrication for my tests to generate objects. In Factory_Girl batch = FactoryGirl.create(:transaction_batch) puts batch # print out a transaction object In Factory Girls batch =…
python
  • 4,403
  • 13
  • 56
  • 103
0
votes
1 answer

Pass variables in fabricator gem and rspec

How would I create a user by passing a variable used as a transient in rspec? What am I doing wrong? controller_tests_spec.rb describe "GET index" do context "with admin user_role" do before(:each) do set_current_admin todo_list1 =…
Beengie
  • 1,588
  • 4
  • 18
  • 36
0
votes
1 answer

Can't fabricate many items with Fabrication-gem and Mongoid

I'm using Fabrication-gem gem, with DatabaseCleaner and Mongoid ORM on RSpec tests. Here are my scripts: spec/support/database_cleaner.rb RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.strategy = :truncation …
Hassen
  • 6,966
  • 13
  • 45
  • 65
0
votes
0 answers

Ran Seed Data on Production Mysql Database Cleardb Heroku Data randomly generated fabricator faker

I have a simple rails app hosted on heroku using their cleardb mysql add on. I was developing on mysql locally. I am having problem with seeding data on production db on heroku. my seed data looks like this in db/seeds.rb. The app is using faker and…
Jngai1297
  • 2,415
  • 5
  • 29
  • 63
0
votes
1 answer

Fabricators not loading

I get an empty array while trying to use fabricators in my specs. My guess is that the fabricator file has not loaded. If I load the fabricator file after RSpec's initialization then a Fabrication::DuplicateFabricatorError is raised. Here's my…
Nathan
  • 1,762
  • 1
  • 20
  • 30
0
votes
1 answer

How use the attributes of a fabricator within the definition of the fabricator?

I have a User and UserProfile models. Currently both models have the attributes first_name, last_name, and email and they must be the same. Later on I will remove these attributes from User but currently I want it that way. A UserProfile belongs_to…
Alexander Popov
  • 23,073
  • 19
  • 91
  • 130
0
votes
1 answer

Fabricating hstore values for Postgresql

As in title, I try to fabricate hash into hstore type column. I have seen question fabricator with hstore attribute, but the solution there does not work for me. My hstore column name is "status", there I want to set three flags: "processed",…
Kulbi
  • 961
  • 1
  • 10
  • 16
0
votes
1 answer

Rspec: NoMethodError

I am writing test cases (Unit testing) for models, and getting an error which i really don't know why... here is my error: Failure/Error: expect(Shelf.enabled.count).to eq 2 NoMethodError: undefined method `enabled' for…
Awais
  • 1,803
  • 22
  • 26
0
votes
1 answer

Rails Fabricator gem with mongoid has_many_and_belongs_to relationship

I'm trying to fabricate a class that has nested elements and has HMABT relationship with another class. Here are my classes class Quote has_and_belongs_to_many :providers belongs_to :user class Provider has_and_belongs_to_many :quotes …
Caner
  • 1,448
  • 23
  • 38
0
votes
1 answer

Prevent RSpec stub from turning associated object into mock

I've recently run into an issue that I'm surprised to have not seen before. I have classes like: class Foo < ActiveRecord::Base belongs_to :bar, inverse_of: :foos end class Bar < ActiveRecord::Base has_many :foos, inverse_of: :bar end and I'm…
JacobEvelyn
  • 3,901
  • 1
  • 40
  • 51
0
votes
1 answer

Why is capybara feature not able to visit new_user_registration_path?

In my feature spec visit_new_session_path works fine and I can see the login form. When I use new_user_registration_path it does not work and just shows homepage. The same issue with click_link, LOG IN works, SIGN UP does not. I have even tried…