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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:06:47+00:00 2026-05-27T07:06:47+00:00

I am running a unit test on a user model in ruby. I am

  • 0

I am running a unit test on a user model in ruby. I am still learning ruby. So when I run

rake test:units

I get this

Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
F
Finished in 0.116562 seconds.

  1) Failure:
test_user_attributes_must_not_be_empty(UserTest) [test/unit/user_test.rb:10]:
<false> is not true.

1 tests, 5 assertions, 1 failures, 0 errors
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ru...]

Tasks: TOP => test:units
(See full trace by running task with --trace)

when I go to file test/unit/user_test.rb:10 I see this line,

require 'test_helper'

    class UserTest < ActiveSupport::TestCase
       test "user attributes must not be empty" do
            user = User.new
        assert user.invalid?
        assert user.errors[:username].any?
        assert user.errors[:name].any?
        assert user.errors[:surname].any?
        >>>assert user.errors[:date_birth].any?<<< Here!
        assert user.errors[:date_reg].any?
        assert user.errors[:email].any?
   end
end

so what is it causing the error? Why am I getting the error there and not anywhere else? like username?

Edit:
My User Class:

class User < ActiveRecord::Base

validates :username, :name, :surname, :email, :presence => true
validates :username, :uniqueness => true

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-05-27T07:06:48+00:00Added an answer on May 27, 2026 at 7:06 am

    What your tests are saying is that if there is any error on all those attributes then the test pass.

    You don’t have a validation on date_birth, so no error is raised, so the test doesn’t pass.

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

Sidebar

Related Questions

I am trying to get a ASP.NET Unit Test running and I keep getting
When running tests in Ruby's unit::test framework, is there a really easy way to
I am getting this error when running some unit tests (using the Test::Unit module
This seems a little weird, when running a unit test to check if the
I am looking to implement a continuous unit test running system, something I have
I was running my first Visual Studio 2008 Unit Test with a WCF Service
I am running on Castle's trunk, and trying to unit-test a controller-action where validation
I have an odd problem in VS2008 running unit tests. When I run the
The way I have my unit test set up is that a user can
I am running a c# unit test (VS 2008). Within the test I do

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.