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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:59:42+00:00 2026-05-17T23:59:42+00:00

I am testing Devise with Rspec using Micheal Hartl source code (railstutorial) Whereas the

  • 0

I am testing Devise with Rspec using Micheal Hartl source code (railstutorial)

Whereas the confirmable module is enabled, I don’t understand why this test pass:

spec/models/user_spec.rb

require 'spec_helper'

describe User do

  before(:each) do
    @attr = { :username => "ExampleUser", 
              :email => "user@example.com",
              :password => 'test1234',
            }
    end

  it "should create a new instance given valid attributes" do
    User.create!(@attr)
  end 
end

Basically, I want to be sure of this code does, it tests the creation on the user, not this validation (cause the user has not confirmed yet and the test returns true) ? This is right?

Moreover, I didn’t provide attribute for password confirmation, and the user is still created!

Is this mean that in the :validatable module there is not (?):

validates :password, :confirmation => true

Thanks to get you view on this!

  • 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-17T23:59:42+00:00Added an answer on May 17, 2026 at 11:59 pm

    one problem is the trailing comma at the end of your each block. second, you are not asserting anything in your test to pass or fail the test, though you are probably erroring out at this point, which is why you are saying it didnt pass.

    you can try assigning the user object to a variable:

      it "should create a new instance given valid attributes" do
        @user = User.new(@attr) 
        @user.should be_valid #=> new will let you know if its valid or not
        @user.save.should be_true #=> another possible assertion to pass/fail the test
        # debug message to give you back why it failed
        puts @user.errors.full_messages.to_sentence
      end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some difficulties in testing devise with shoulda: 2) Error: test: handle :index
I've recently just added Devise to my first Rails3 app, and I'm having a
I'm trying to devise a method that will be able to classify a given
I have a situation where I need to write some unit tests for some
Program received signal: 0. warning: check_safe_call: could not restore current frame What is this
I have a screen with several UISwitch controls. On my iPhone simulator this screen
I am developing as site for mobile devices which requires the user to select
not much of a programming question, but development related still, I'm starting Android development
I know this has been asked but I'm still confounded. I'm trying to build
Here is what I'm trying to do .. Whenever event occurs, device should vibrate

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.