Displaying 20 results from an estimated 10000 matches similar to: "Load dummy data using Factory girl"
2012 Nov 12
1
Factory girl associations and rspec
Hi,
I am trying to test factory girl associations basically I have a user
model and status model , what is supposed to happen is a user has many
statuses and a status belongs to a user. I have tried to model this in
factory girl as you can see in the files. When I try to execute the test
I get
Failure/Error: visit("/users/#{user.id}/statuses/#{status.id}")
2013 Mar 28
0
Can not determine issue in my factories with factory girl in rspec
Hi Folks,
I hope you''re doing good. Sorry for a long email. I am just trying my best
to learn something new and, need your help to understand/ sort a small
issue which I am not able to figure out.
I have create couple of factories and created some examples for rspec for
one of my projects. I have got everything working on my local. Even, my
specs are green on local for both ruby
2010 Dec 12
5
Fixtures and unit tests - no such file to load
Hello all,
I''m having some issues with my test fixtures and unit tests and am
hoping somebody has an idea about how to fix it.
Background:
I have a table in my legacy database called tp_approval_step.
For this table I have a fixture called tp_approval_step.yml
I have a model called ApprovalProcessStep that uses set_table_name
''tp_approval_step''
In my test file,
2010 Jun 03
2
creating fixtures for has_many :through
I''m stymied at how to create a fixture that establishes a has_many
:through relationship.
I''ve watched the railscast at:
http://media.railscasts.com/videos/081_fixtures_in_rails_2.mov
... but that''s for HABTM relationships. I''ve read:
http://www.ruby-forum.com/topic/145676
but that ultimately doesn''t answer any question. So with no further
ado:
2009 Jun 02
3
valdate_presnce_of email, :if => :validate_id + Factory girl
Hi
In the model I have User
attr_accessor :validate_email_id
validates_presence_of :email ,:if => :validate_email_id
Could anybody please tell me how can I define a Factory for the above?
Thanks in advance
Sijo
--
Posted via http://www.ruby-forum.com/.
2010 Feb 04
2
preload test data from factory_girl
Is there a way to preload common data made by factory_girl to speed up
tests instead of recreating these common data at the beginning of
every test. For example, I want to have 10 users premade at the
beginning of every test.
I found this http://agilewebdevelopment.com/plugins/factory_data_preloader
But the page says that this plugin does not "play nice" with
autotest. But I use
2013 Feb 28
1
Validation Failed: Userkey has already been taken, Email has already been taken
Hi,
I am using Factory girl with rspec and capybara for testing my rails
appliction. I have the below code
FactoryGirl.define do
factory :user do |f|
f.email "sss1 at gmail.com"
f.userkey "12ssd345q62"
end
end
When I run the test it is failing as "Validation Failed: Userkey has
already been taken, Email has already been taken".
What could be the reason for
2010 Sep 01
1
Faking Paperclip has_attached_file with Factory girl?
Hello!
I wonder if it''s possible to simulate Paperclip''s has_attached_file
with Factory Girl and then test it with Rspec. I don''t get it to work.
My factories.rb file looks like this:
Factory.define :user do |user|
user.name "Anders"
user.email "user-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org"
user.password
2011 Jan 20
11
RSpec / Cucumber painfully slow Rails 3 OSX
I am working on my first Rails BDD project with extensive tests since
starting out with Rails a few years ago.
Running RSpec or Cucumber is really slow. I''m using Rails 3 and RSpec
2.
To run one model spec with only 5 tests takes almost 1 minute! When it
finishes it says it took only 0.9 seconds to run the actual test. So
obviously it is loading the environment that takes so long. I just
2010 Jan 29
4
requiring records in the DB before testing
Is there any way I can require a small set of data be in the test
database before any tests are run? (unit, functional, integration,
cucumber, etc)
Any way besides using fixtures, that is.
Overload a rake task?
Modify test_helper?
Any ideas?
(Simple Case: I have to have a minimal set of user roles defined
before any users can be created)
--
You received this message because you are subscribed to
2010 Jul 08
3
my web app seed data and cucumber
I''m writing a web app which is used a SaS. Each customer has their own
db and app directory. I have a rake task which creates all necessary
minimum data to run their website: default rights and roles, a
superadmin user, a "us_states" table already populated, some local
depots and terminals (it''s a logistics app).
I don''t have any cucumber scenarios for it and
2011 Jan 17
4
Factory Girl and attr_accessor with validation
I have a problem with a recent change to one of my models when created
via Factory.create.
class User < ActiveRecord::Base
attr_accessor :tc_check
validates :tc_check, :presence => true, :acceptance => true
...
end
The following definition fails, when calling
Factory.create(:valid_user)
Factory.define :valid_user, :class => User do |u|
u.email
2008 Jul 05
5
Does RSpec work nicely with UUID primary keys?
I have my application happily generating UUID primary keys using the
uuidtools gem.
But the auto-generated specifications created by "script/generate
rspec_scaffold...", etc, assume that one is using a sequential integer
primary key.
For those who have hit this same issue, is it just a matter of rewriting
the auto-generated specifications to take this into account, or does one
have to
2010 Sep 27
3
having some issues with factory_girl and bundler...
Hi All
Need some brilliants minds here :)
I''m using Rails 2.3.8 & ruby 1.8 (I know, I know... )
I''ve move my gems from .gems to Bundler, but I''m having some issues with
Factory_girl when I rake spec
"uninitialized constant Factory"
I''m following the instructions from http://gembundler.com/rails23.html.
Basically:
- grab all config.gem and place
2010 Sep 25
3
Factory_girl association with specific values
Hope this should be simple: I have a User model and a Role model. Factories
for each.
When I create a User using FG, I want to assign a specific role. Cant seem
to figure out how to do this, getting errors like: uninitialized constant
SysadminRole for doing things this way:
Factory.define :user do |u|
u.practice_id { |a| a.association(:practice).id }
u.password ''password1''
2008 Mar 18
11
"Why not MockEverthing" or why use fixtures for all tests?
Hello fellow RSpec users.
Before you all start warming up your flame throwers please let me
explain my Subject line.
I''ve been working over 4 months on a large Rails project with a few
other developers. Test coverage was spotty at best, though they
*were* RSpec tests. One of the other developers and I had started
adding more tests, mostly controller tests using the methodology
2013 Aug 22
1
How do I deal with ActiveRecord::RecordInvalid: Validation failed:
Hello all,
I am currently writing model tests in rails 4. I am attempting to add an
error to a reservation object if the total number of reservations for a
given date and time has reached a pre-determined limit.
When my test runs, it is hitting the appropriate code but it is raising the
following error as opposed to just giving me an error in the object that I
can use.
2007 Sep 26
10
How do I best setup data for Story Runner?
Just started looking at the Story Runner integration, and am
converting a few Rails integration tests to get a feel for it.
My integration tests relied on fixtures, and since my models have a
significant amount of validation (and hence need valid data unless I
save without validation), this has made setup easy.
With stories however, I''m wondering what the recommended approach is.
2010 Aug 06
4
Object/Record foreign key IDs set to zero
Hello,
Hope no one minds me just jumping in here with a question.
I''m completely new to Ruby on Rails. I''ve been reading "Simply Rails
2", and following their examples. I reached a point where the unit
tests were unexpectedly failing. Upon investigation, I discovered that
when Rails loads the fixtures, the foreign keys aren''t being populated
with the foreign
2012 Jun 08
1
[Rails 3.2.5] Rails: unit test fixture_path : fixture_file_upload cannot find the file ...
I am trying to perform a test unit, using FactoryGirl
include ActionDispatch::TestProcess
FactoryGirl.define do
factory :article do
.......
photo { fixture_file_upload ''/files/test.jpg'', ''image/jpg'' }
end
end
IN mt test_helper.rb I defined the fixture_path
def fixture_path
File.dirname(__FILE__) + "/fixtures/" #