factory-bot Questions
1
Solved
I was wondering if anyone knows whether it's possible to use FactoryGirl without any of the aforementioned prerequisites.
I would like to use it to generate on-the-fly test data when driving UI au...
Tomkin asked 21/6, 2014 at 16:44
6
Solved
Recently I switched from fixtures to factory_girl to test my Ruby on Rails application. If I run rake test:units, to run the tests in my /units directory, they all run perfectly. The same is true i...
Oliviaolivie asked 27/7, 2009 at 16:43
2
Solved
I got following problem:
In my application i use inheritance to define my user model:
class User
include Mongoid::Document
field :name...
field :bla...
end
class CustomUser < User
field ...
Jenelljenelle asked 12/11, 2012 at 12:40
2
Solved
I have set up Rspec with a rails4 app however the tests are returning:
Failure/Error: user = Factory(:user)
NoMethodError:
undefined method `Factory' for #<RSpec::Core::ExampleGroup::Nested_4...
Knudsen asked 22/5, 2014 at 9:18
2
Solved
I'm trying to do something I think should be fairly simple with Factory Girl and can't quite get it. A user has many stories and I'm testing viewing a user's profile page, which lists their created...
Forestation asked 17/5, 2014 at 21:35
2
Solved
While trying to write rSpec tests, im a bit confused on how to generate FactoryGirl records with associations.
Basically, I have a Quiz model and a Question model. They are related through a HABTM...
Bradshaw asked 6/7, 2013 at 0:28
1
Solved
I have many models which can be authorable (have an author field) and/or tenancyable (have a tenant field). So, I wrote concerns for both of them.
The problem is in tests. I had used the shared_ex...
Roorback asked 21/4, 2014 at 19:42
4
I am testing a typical Rails model with a typical factory:
# My model uses a 3-letter uppercase airport code,
# such as "ATL" for Atlanta, "BOS" for Boston, etc.
class Airport < ActiveRecord::...
Board asked 29/4, 2014 at 2:12
1
Does anyone know the proper way to create PaperClip 4.0 attachments with factory_girl, bypassing any of the PaperClip processing and validation?
I used to just be able to do the following in my f...
Bullpen asked 3/2, 2014 at 22:29
3
Solved
Given a standard has_many relationship between two objects. For a simple example, let's go with:
class Order < ActiveRecord::Base
has_many :line_items
end
class LineItem < ActiveRecord::Ba...
Transit asked 19/7, 2013 at 20:17
1
Solved
I'm looking to DRY up my test suite. Trying to create a trait that represents specific values of a has_many relationship on the parent factory. Ideally these values would be created from a separate...
Misreport asked 25/3, 2014 at 2:5
6
Solved
Factory Girl is a handy framework in rails for easily creating instances of models for testing.
From the Factory Girl home page:
factory_girl allows you to quickly define prototypes for ...
Repulse asked 12/6, 2009 at 12:58
1
I get an error (shown below) when using the factory below. It is temporarily fixed by running rake db:test:prepare, however, this only fixes it for one running of the test. What can I do for a more...
Uncut asked 28/2, 2014 at 19:14
2
models/message.rb
class Message
attr_reader :bundle_id, :order_id, :order_number, :event
def initialize(message)
hash = message
@bundle_id = hash[:payload][:bundle_id]
@order_id = hash[:pay...
Crackerbarrel asked 31/7, 2013 at 10:30
2
Solved
I want to DRY up the after create/build hooks in my Factory:
FactoryGirl.define do
factory :poll do
sequence :title do |n|
"MyPollTitle#{n}"
end
sequence :description do |n|
"MyPollDescrip...
Michaelmichaela asked 18/7, 2012 at 5:51
2
Solved
I'm using rspec and Factory Girl for testing. When testing the POST #create section of my posts_controller I'm getting the error in the title.
Failures:
1) PostsController POST #create with vali...
Heretofore asked 15/2, 2014 at 19:24
1
Solved
Alright guys. How does this even make sense? The two nested factories (which is considered an inheritance by FactoryGirl) should not conflict with each other. What the heck is going on? Either it's...
Quinnquinol asked 3/2, 2014 at 18:18
1
Solved
I have a new Rails 4 project with FactoryGirl and rSpec. In my spec_helper.rb I have:
# lots of stuff
RSpec.configure do |config|
# more stuff
config.include FactoryGirl::Syntax::Methods
end
I...
Islean asked 30/1, 2014 at 23:53
1
In RSPEC, the behavior of Let is to memoize across a single example ( it block ), but in some cases this can lead to some potentially nasty side effects as far as timing.
I've noticed that if you...
Lipsey asked 26/12, 2013 at 22:25
2
Solved
I added some confirmation dialog boxes for my Rails 3.1 application and, prior to that, their corresponding tests. Following the model of Railscast #257, I added ':js => true' to the test, added da...
Jaban asked 9/1, 2012 at 16:40
1
Solved
We have two web apps that share the same database and models. To keep it DRY we created an engine that contains all those models. This engine is included in the respective apps via the Gemfile. We ...
Protero asked 28/11, 2013 at 8:58
2
Solved
I'm trying to use FactoryGirl to build a Hash that returns something like this:
=> {"3"=>"1", "6"=>"Word"}
I'm getting close but not 100% there yet...
The first factory definition i t...
Denitadenitrate asked 17/12, 2013 at 21:25
3
Solved
I have a standard has_many relationship (Booking has many Orders) with validation that a Booking does not get saved without at least one Order. I'm trying to replicate this with my FactoryGirl fact...
Erased asked 13/12, 2012 at 1:6
5
Solved
I just added validations for a carrierwave image to a model and now tests run really slow. How can I speed up this process? I feel like there must be a better way.
I've been running without vali...
Fala asked 8/3, 2012 at 9:16
2
Solved
I am trying to test a "Post create" action with Rspec. The code is as follows:
def valid_attributes
{
:zone => Flymgr::Zone.new(:countries => Flymgr::ZoneCountry.first,
:name => 'USA'...
Potful asked 11/5, 2012 at 11:46
© 2022 - 2024 — McMap. All rights reserved.