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

  • SEARCH
  • Home
  • 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 8848115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:21:08+00:00 2026-06-14T12:21:08+00:00

I think this could be related to the issues I described in this question

  • 0

I think this could be related to the issues I described in this question.

I can’t figure out why Capybara is not able to test the sign up form on my rails app when using Factory Girl to create user Factories. I keep getting a email has already been taken error. Here’s my Factory:

FactoryGirl.define do
  sequence :email do |n|
    "email#{n}@example.com"
  end

  factory :user do
    email
    password "secret"
    password_confirmation "secret"
  end
end

Here’s my sign up test:

require "test_helper"

describe "Signup integration" do

  before(:each) do
    visit signup_path
  end

  it "successfully routes to the signup page" do
    page.text.must_include "Sign Up"
  end

  it "signs up a new user" do
    user = FactoryGirl.create(:user)
    fill_in "user_email", :with => user.email
    fill_in "Password", :with => user.password
    fill_in "Password confirmation", :with => user.password_confirmation
    click_button "Create User"
    current_path == "/"
    page.text.must_include "Signed up!"
  end  
end

And here’s my test_helper.rb:

ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "minitest/autorun"
require "capybara/rails"
require "active_support/testing/setup_and_teardown"

class IntegrationTest < MiniTest::Spec
  include Rails.application.routes.url_helpers
  include Capybara::DSL
  register_spec_type(/integration$/, self)

  def last_email
    ActionMailer::Base.deliveries.last
  end

  def reset_email
    ActionMailer::Base.deliveries = []
  end
end

class HelperTest < MiniTest::Spec
  include ActiveSupport::Testing::SetupAndTeardown
  include ActionView::TestCase::Behavior
  register_spec_type(/Helper$/, self)
end

Turn.config.format = :outline

I’m not really sure what could be wrong with that. If I add the Capybara save_and_open_page method to each line it is able to get all the way to the password field, but Capybara is not able to fill out the password field. It adds a unique email address like email3@example.com to the email field, but then can’t add the Factory Girl password. If I put a plain text password into the test (fill_in "Password", :with => "password") it is able to fill out the field, but that doesn’t seem like the proper way to test this.

I’m also not sure if it could be related to a login test that I have in the app as well? Could the issue be that Capybara is logged in as another user from the login test? If so, how do you clean out the session your tests?

Finally, here’s my gemfile, in case that is relevant:

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'jquery-rails'
gem 'pg'
gem 'heroku'
gem 'taps'
gem 'sorcery'
gem 'bootstrap-sass'
gem 'simple_form'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

group :test do
  gem 'minitest'
  gem 'capybara'
  gem 'capybara_minitest_spec'
  gem 'turn'
  gem 'factory_girl_rails'
end
  • 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-06-14T12:21:09+00:00Added an answer on June 14, 2026 at 12:21 pm

    The problem is probably in this line

    user = FactoryGirl.create(:user)
    

    try to change it to

    user = FactoryGirl.build(:user)
    

    The FactoryGirl.create creates an instance of User object and saves it to the database. build creates an instance, but does not save it to the DB.

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

Sidebar

Related Questions

I think this could be a very easy question for you. But I have
I am using Ruby on Rails, but I think this question could be applied
This could be an amazingly dumb question, but .... I don't think a standard
I don't think that this could be done in C#, but posting this just
I could solve this using loops, but I am trying think in vectors so
(I could probably think of a better title for this and open to suggestions)
I think the answer to this is no going in, but I could use
You might think that this question is already answered. However, I couldn't find the
(I think this is a pretty basic question on OOP, but unfortunately I wasn't
This question was previously asked Here , but not answered, And failed to find

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.