Displaying 20 results from an estimated 23 matches for "factorygirl".
Did you mean:
factory_girl
2012 Nov 08
1
validates_uniqueness_of(*attr_names) w scope not working in unit test
Rails 3.2.8
Very strange , it works in dv mode console , but not in a unit test
class User < ActiveRecord::Base
belongs_to :subdomain
validates_uniqueness_of :email, :scope => :subdomain_id
class UserTest < ActiveSupport::TestCase
def initialize_user
@booboo = FactoryGirl.create(:subdomain, name: "booboo")
@coocoo = FactoryGirl.create(:subdomain, name: "coocoo")
FactoryGirl.create(:user, subdomain_id: @booboo[:id], email:
"user.doe-PV5Ro7/Mrj4@public.gmane.org", password: "UkZaHWcy", password_confirmation:
"UkZa...
2013 Oct 08
1
Trouble with rspec and FactoryGirl Sequence
I''m following Michael Hartl''s Ruby on Rails 3 Tutorial but I''m using
Rails 3.2.8 and FactoryGirl 4.2.0 and rspec 2.14.1 I''m in chapter 10
trying to generate tests for pagination (using will_paginate 3.2.5 which
works fine in dev)
I can get FactoryGirl to test just fine if I don''t use Sequence but I
can''t seem to figure out the correct syntax to test pagination usi...
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 this. I am new to R...
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__)...
2014 Feb 18
0
How to Test Multimodel Paperclip attachments?
I'm using Rspec and FactoryGirl to create specs for multimodel paperclip
attachments. From searching other questions, it seems like a single
image attachment is more common.
Car.rb
class Car < ActiveRecord::Base
has_many :uploads, dependent: :destroy
validates :uploads, presence: { message: 'You must upl...
2013 Aug 22
1
How do I deal with ActiveRecord::RecordInvalid: Validation failed:
...st>''
I was wondering if anyone can give me an ideas of how to deal with this.
My test environment is using shoulda, faker, and factory_girl
test/models/reservation_test.rb:
setup do
List.create(name: ''reservation_limit'', values: 20)
@reservation = FactoryGirl.build(:reservation)
end
should "remove unavailable times if reservation limit for time slot is
full" do
20.times{ FactoryGirl.create :reservation }
assert_equal false, FactoryGirl.create(:reservation), "reservation
was created after total reservation for time s...
2012 Nov 12
7
RSpec: controller POST create
...(required)>''
If my understanding is correct, be_persisted is testing if the newly
created model instance is properly stored in DB.
I understand that my way is rather opposite: building test methods after
setting actual codes. But first I need to understand RSpec.
I have also setup FactoryGirl
FactoryGirl.define do
factory :plan do
sequence(:give_take) { |n| [ 0, 1 ][n%2] }
sequence(:weight) { | n | n }
sequence(:check_in) { |c| [ true, false ][c%2] }
sequence(:flight_name_id) { |n| n }
day_departure Date.new(2012, 12, 1)
end
end
which does work.
Question:
Can...
2012 Nov 18
3
remarkable activerecord association RSpec
...kable activerecord for association. i''ve installed
remarkable and remarkable activerecrod both gem. i''ve added both gem in
my Gemfile. i''ve added "remarkable_activerecord" as required in
spec_helper.rb.
describe Authentication do
FactoryGirl.build(:authentication).should
belong_to(:user)
end
it "has a valid factory" do
FactoryGirl.create(:authentication).should
validate_presence_of(:uid)
end
i got error: : undefined method `belong_to'' and undefined method
`validate_pr...
2013 Jun 18
1
Getting rspec error: Net::SMTPServerBusy: Relay access denied
...#39;'
require ''capybara/rspec''
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
endend
Spork.each_run do
FactoryGirl.reloadend
test.rb:
Upficial::Application.configure do
config.whiny_nils = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.delivery_method = :testend
The test itself is very straightforward:
require ''spec...
2011 Sep 07
6
FactoryGirl doesnt produce unique names?!
Hey,
I got following very simple test case:
require ''spec_helper''
describe Country do
it "should create a new instance given valid attributes" do
Factory(:country)
end
end
Factory looks like:
Factory.sequence :country_name do |n|
"Country #{n}"
end
Factory.define :country do |c|
c.name Factory.next(:country_name)
c.nationality "Foo
2011 Nov 18
1
What does :count actually mean in assert_select?
Hi guys,
I tried reading up the RSPEC Book (Dec 2010) and googled a bit but I
could not find anything.
I''m using Rspec2.
Example:
spec/factories/categories.rb
======================
FactoryGirl.define do
factory :category_intakes, :class => ''category'' do
name ''intakes and filters''
description ''airfilters and etc.''
created_by 1
updated_by 1
end
factory :category_audio, :class => ''category...
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}")
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
2012 Nov 17
0
How to get more debug information in test log ?
Im one of my unit tests, I got an error I cannot even start looking for the
issue as few information are logged ...
Using the test console , there is no error at all :
> rails console test
>> Loading test environment (Rails 3.2.9.rc3)
> site1 = FactoryGirl.create(:cms_site, label: "booboo")
>> BEGIN
..
..
>>
but running my tests > unit
> ruby -Itest test/unit/user_test.rb -n
"/should_save_user_with_required_fields/"
>> STARTED
>> Error: test_should_save_user_with_required_fields(UserTest)
NoMet...
2014 Feb 11
0
Cucumber test question
Hello all,
I am trying to understand when I try to run a test in cucumber what I am
missing that it is failing. I am using FactoryGirl to create my records and
using cucumber to test my logic however I know that I am doing something
wrong in my testing I just can't seem to figure out what. Here is what I
have:
Feature:
Feature: All features related to staff info
Scenario: notification for empty shirt size
Given ther...
2014 Jun 09
0
How can I test my controller via rspec for something other than response.should be_success?
1) Right now this is just testing a successful response. However, since
I've gone and created a Post via FactoryGirl... how can I test the
@post.id equals one of the id's being returned by the get: index json?
describe Api::V1::PostsController do
context 'Post' do
before(:each) do
@post = FactoryGirl.create(:post)
end
context '#index' do
it "should have...
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''
2013 Sep 04
2
Speed up image processing of Paperclip in Acceptance Tests
...Slow factory notices
which are populated byfactory_girl. These Slow factory things heavy slow
down the feature specs, I think, even feature specs are intrinsic slow
specs. Then I had some inspect and found out most of the Slow factory was
caused bypaperclip. We had model using paperclip here:
FactoryGirl.define do
factory :asset do
image Rails.root.join(''spec/fixtures/sample.jpg'').open
endend
So I wonder if there''s a way like test mode for paperclip to speed up
tests. I have simple solution here: Just copy the original file instead of
actually crop it.
The sta...
2009 Jun 01
0
smart data loading
...eleases. I''m using fixtures currently but maintaining the
foreign key relationships is getting more difficult as the app grows
larger.
I''d like something that''s aware of my foreign keys constraints and
knows to load the data in the proper order.
I''ve looked at FactoryGirl and seed_fu so far but would love to hear
of any alternatives.
Thanks,
--
Greg Donald
http://destiney.com/
2010 Jul 19
0
Forking and integration tests
...bug.
I need to simulate the concurrent requests that can result in the
original bug. I thought of many ideas and decided to go with forking 2
or more processes (from within the test code) in which I issue a get
request to my controller-action.
Setup: MySQL DB, Rails 2.3.5, Ruby 1.9.1, Shoulda and FactoryGirl.
Unfortunately this test code doesn''t do the trick.
When I try to remove_connection before forking and then
establish_connection inside the children processes, I don''t find data
when asserting.
When trying to use the same connection among the parent process and its
children, I...