On Thu, Feb 28, 2013 at 12:57 PM, ruby rails <li...@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 "s...@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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to