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 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

Unit testing is, roughly speaking, testing bits of your code in isolation with test
Testing: return request.getCookies() == null; is not an appropriate way test. Is there another
Unit testing and ASP.NET web applications are an ambiguous point in my group. More
For testing purposes I have to generate a file of a certain size (to
Unit testing sounds great to me, but I'm not sure I should spend any
Unit testing with C/C++: What do you teach people who either did not do
for testing purposes i need an recursive directory with some files, that comes to
While testing a console app, I set the properties of the console window to
For testing purposes I need to get my Outlook 2003 addin (vb.net) disabled so
For testing exception handling in the case of a broken connection it is useful

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.