RSpec + FactoryGirl should_receive failing
By : user3775665
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I think you are doing it wrong. The @vendor object in specs is another one that in your controller, so it doesn't receive "update_attributes" method. code :
Vendor.any_instance.should_receive(:update_attributes).with(FactoryGirl.attributes_for(:vendor))
expect{
do_update
}.to change(...)
|
FactoryGirl Rspec Model Test Failing
By : Ahmed ElMenyawi
Date : March 29 2020, 07:55 AM
this will help The association definition is incorrect. Try to use the documented way code :
factory :hour do
job #this is enough
first_name "John"
last_name "Smith"
hours 8
date_worked "2013-04-27"
description "Did some work"
end
|
Rspec and FactoryGirl Uniqueness Failing
By : M. Iván Jaen M.
Date : March 29 2020, 07:55 AM
With these it helps I figured it out! On a whim, I checked out the test database and noticed that a Person object was lingering around. So, it actually wasn't the build(:person).should_not be_valid that was raising the Mongoid exception. It was the create call on the line before. Clearing out the DB and running the spec again passed, but again the data was persisting. I double checked my spec_helper.rb file and noticed I wasn't calling start on the DatabaseCleaner. My updated spec_helper.rb file looks like this, and now everything works: code :
# Clean up the database
require 'database_cleaner'
config.mock_with :rspec
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
|
Rspec + FactoryGirl + Faker tests failing randomly
By : user3034552
Date : March 29 2020, 07:55 AM
To fix the issue you can do You changed the locale to something other than the rails default and are getting errors that don't have a translation into that locale. An easy work-around would be to temporarily change the locale back to the default so you are more likely to get the actual error message (Looks like activerecord is trying to tell you something but it doesn't know how to say it in pt-BR). It will tell you this error in English, but it seems like you know English so that shouldn't be a problem.
|
Failing validation when trying to create a list with Rspec and FactoryGirl?
By : GaliSrikanth19
Date : March 29 2020, 07:55 AM
will be helpful for those in need The problem is that your are generating a random email just once. You need to execute the Faker::Internet.safe_email code, inside a block, like this: code :
FactoryGirl.define do
factory :user, aliases: [:author] do
email { Faker::Internet.safe_email }
end
end
|