You are probably (should be) using a sequence on email in your user
factory.  If you create a user then you should reference the email from the
created user i.e.

user = FactoryGirl.create(:user)
fill_in 'user[email]', :with => user.email


On 4 November 2013 15:32, BitGub <notifications@github.com> wrote:

> In spec/models/user_spec.rb:
>
> > @@ -44,18 +52,17 @@
> >
> >    describe "when email address is already taken" do
> >        before do
> > -        user_with_same_email = @user.dup
> > -        user_with_same_email.email = @user.email.upcase
> > -        user_with_same_email.save
> > +        @user_with_same_email = @user.dup
> > +        @user_with_same_email.email = @user.email.upcase
>
> This was an interesting one actually. My email uniqueness test was failing
> all of a sudden when I switched to creating my user via FactoryGirl.
>
> I found out that when i did: it { should_not be_valid } Rspec looks at the
> subject which by default is User.new. this worked when I was creating my
> user instance that way. so I had to tell it to check the
> user_with_same_email instead of User.new (
> http://stackoverflow.com/questions/11378546/rspec-uniqueness-email-test-fails-with-factorygirl)
> hence the change.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/BitGub/zucono/pull/6/files#r7402679>
> .
>