Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7082103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:00:19+00:00 2026-05-28T07:00:19+00:00

I am learning rais from the rails tutorial book: http://ruby.railstutorial.org/chapters/sign-in-sign-out#fnref:9.14 I am working on

  • 0

I am learning rais from the rails tutorial book: http://ruby.railstutorial.org/chapters/sign-in-sign-out#fnref:9.14

I am working on the exercise. The assignment is to create a sign in method in spec helper so that it can be used in integration tests. He gave the code already:

def integration_sign_in(user)
    visit signin_path
    fill_in :email,    :with => user.email
    fill_in :password, :with => user.password
    click_button
  end

So, in my layout_links_spec.rb integration test, I plan to use it.

before(:each) do
      @user = Factory(:user)
      visit signin_path
      fill_in :email,    :with => @user.email
      fill_in :password, :with => @user.password
      click_button
      # integration_sign_in(Factory(:user))
    end

I comment everything out and use integration_sign_in(Factory(:user)). The error I get is

ActiveRecord::RecordInvalid:
       Validation failed: Email has already been taken

However, if I use the original which looks so similar to the integration_sign_in function, the tests passes. Can someone provide an explanation please?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:00:19+00:00Added an answer on May 28, 2026 at 7:00 am

    Sounds like your :user factory is returning the same email address each time it makes a user. Because you have the before(:each) it’s going to be making and stuffing into the DB more than one user, and they will all have the same email.

    If you post your factory we can probably tweak it to use a sequence or find an alternative solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently following the Learning Rails Screencasts at http://www.buildingwebapps.com/learningrails , making any necessary changes to
Learning Ruby and Rails. In following the getting started guide if I invoke rails
Learning from my last question , most member names seem to get included in
When learning new languages such as C++ from PHP, does reading other language snippets
Learning Ruby. Needed to create a hash of arrays. This works... but I don't
Learning from my broad question here ... I was wondering how I could go
Learning how to do a master page in asp.net. Trying to figure out how
Learning C++ and see the class laid out like this: class CRectangle { int
For learning purposes, I'm looking for open source Rails projects that exemplify idiomatic usage
Learning the basics of XML for the first time from W3C tutorials. How are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.