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 8436907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:18:23+00:00 2026-06-10T07:18:23+00:00

Using rails, devise, rspec & factorygirl: Trying to create some tests for my site.

  • 0

Using rails, devise, rspec & factorygirl:

Trying to create some tests for my site. I’m using the confirmable model for devise so when I create a user using FactoryGirl, the user isn’t confirmed.

This is my factories.rb:

FactoryGirl.define do
  factory :user do
    full_name             "Aren Admin"
    email                 "aren@example.com"
    password              "arenaren"
    password_confirmation "arenaren"
    role_id               ADMIN
  end
end

And this is my rspec test file:

require 'spec_helper'

describe "Admin pages" do

  subject { page }

  describe "home page" do
    let(:user) { FactoryGirl.create(:user) }
    before { visit admin_home_path }

    it { should have_content("#{ROLE_TYPES[user.role_id]}") }
  end
end

I’m getting an error because the user is not confirmed. By searching around I’m pretty sure I need to use the method ‘confirm!’ and that it belongs in the factories.rb file, but I’m not sure where to put it.

  • 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-10T07:18:24+00:00Added an answer on June 10, 2026 at 7:18 am

    Try user.confirm! in your before block

    found here

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

Sidebar

Related Questions

I'm using rails 3 and Devise and i'm trying to restrict some actions to
I'm retroactively writing some tests, using RSpec, for a Rails project. I'm using the
I'm using Rails, iOS, and devise. I want to read a single user. The
I have a class User in Rails using Mongoid and Devise. I can't seem
I am using Rails 3 and Devise to create an app where users arrive
I'm using rails 3 with devise. I have a User table with fields: email,
I'm using Rails 3 with Devise for user auth. Let's say I have a
I'm using Devise for my User model and sessions control. I'd like to use
I created the /views/user/ folder using rails g devise:views but devise is still using
I'm using rails 3.1 with Devise for user authentication... I'm having trouble either getting

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.