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

spec and fabrication validating mailer. Fabrication::UnfabricatableError: No class found for

I'm validating a mailer using rspec. The problem is that when I want to test the diffusion (multiple deliverers mailer) rspec give me an error. my Fabricator: Fabricator(:message) do email(count: 1) {"proof@example.com" } subject:"Hackety-hack…
hcarreras
  • 4,442
  • 2
  • 23
  • 32
0
votes
1 answer

How can I dry many to many association assignments in rspec?

Every time I want to create an Issue, I need to link User with Label. User has_many Labels and Labels has_many Users. The problem is that I need to repeat this in a lot of specs every time I create an Issue. let(:label) { Fabricate(:label)…
Luccas
  • 4,078
  • 6
  • 42
  • 72
0
votes
1 answer

Fabrication::MisplacedFabricateError while using Fabrication Gem on Rails 2.3.16

I am using Fabrication gem v-2.5.0 on Rails 2.3.16 but get the following errors when I run the unit test cases: Below is the code snippet : First case Fabricate(:some_modal) Fabrication::MisplacedFabricateError: # from…
0
votes
2 answers

Rails Factories association fail

I've been fighting with this all day. The problem is the same with Fabrication or FactoryGirl so I guess it has to do with Active Record or Rails. Let's take the following code: # app/models/category.rb class Category < ActiveRecord::Base …
karellm
  • 1,843
  • 1
  • 20
  • 23
0
votes
1 answer

Rspec model test with Fabricator & let(...) format. Console shows no data in databse but there is.

I don't understand why it returns empty when I type "Video.all" first time in console after it did not pass the test, but if I specify them like "video" & "video2", and then I type "Video.all" it correctly returns the 2 videos. Does anyone know why…
YHDEV
  • 477
  • 8
  • 22
0
votes
1 answer

how is this model spec working in the discource test suite

I am looking through the discourse source code here https://github.com/discourse/discourse/blob/master/spec/models/invite_spec.rb and see code like this: require 'spec_helper' describe Invite do it { should belong_to :user } it { should…
timpone
  • 19,235
  • 36
  • 121
  • 211
0
votes
1 answer

How to set polymorphic relations using Fabricator-gem?

I am trying to setup fabricator-gem to handle my models for testing. The problem I am running into is that it doesn't seem to be able to handle polymorphic relations. I am using MongoDB as my database and Mongoid as my ORM. Consider this…
Max
  • 15,157
  • 17
  • 82
  • 127
0
votes
1 answer

get mongoid <-> fabrication not working habtm

I have a question to the "has_and_belongs_to_many" and "accept_nested_attributes_for" in context to fabrication and mongoid I have a Location which can have many services class Location include Mongoid::Document field :name field…
Jan
  • 12,992
  • 9
  • 53
  • 89
0
votes
1 answer

fabrication with mongoid - wrong number of arguments

I'm using Mongoid. I have an object : class Employee include Mongoid::Document field :name_first, type: String field :name_last, type: String field :name_other, type: Array, default: [] field :title, …
Dan Donaldson
  • 1,061
  • 1
  • 8
  • 21
1 2 3 4
5