ruby rails
2013-Feb-28 17:57 UTC
[rspec-users] 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 Rspec. -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2013-Feb-28 18:55 UTC
[rspec-users] Validation Failed: Userkey has already been taken, Email has already been taken
On Thu, Feb 28, 2013 at 12:57 PM, ruby rails <lists at ruby-forum.com> wrote:> 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 Rspec.If you have unique validations on email and userkey, you''ll want the factory to generate diff values every time. Take a look at https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#sequences I appreciate that you''re new to RSpec, and lists like this exist to provide help, but this is the 2nd time you''ve asked FactoryGirl questions that could be answered by reading the FactoryGirl docs. Please do so before the next question about FactoryGirl and, if it''s about FactoryGirl, you probably want to hit up https://groups.google.com/forum/?fromgroups#!forum/factory_girl, and restrict your questions on this list to those actually about rspec. If you''re not sure what the cause is, and can''t figure out where else to send your question, we can point you in the right direction. Cheers, David
Apparently Analagous Threads
- How do I deal with ActiveRecord::RecordInvalid: Validation failed:
- RSpec / Cucumber painfully slow Rails 3 OSX
- Getting rspec error: Net::SMTPServerBusy: Relay access denied
- validates_uniqueness_of(*attr_names) w scope not working in unit test
- Matching username in ssh_config