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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:42:49+00:00 2026-05-20T05:42:49+00:00

I trying to spec validations of my model this is my model class Account

  • 0

I trying to spec validations of my model this is my model

 class Account < CouchRest::Model::Base
         property :user, String 
         property :password, String
         property :name, String
         property :email, String
         property :activate, TrueClass, :default => true
         validates_presence_of :user, :password, :name, :email
         validates_length_of :password, :in => 6..15, :if => lambda{|account| !account.password.blank? }
         validates_uniqueness_of :user, :if => (lambda{|account| !account.user.blank?})
  end

and into my model_spec i’m trying to do this

account = Account.new
account.should have(1).error_on_presence_of(:email)

But instead 1 error, I’m getting 6

I think that might be caused by validates of couchrest but not sure.

Can someone clarify this for me please?

P.S.: If I validate the same model into console I get 4 errors corresponding the four empty properties

  • 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-20T05:42:50+00:00Added an answer on May 20, 2026 at 5:42 am

    It seems you’re expecting 1 error, but there are actually 6. To figure out what is in the error hash, you can set a temporary expectation:

    `account.errors.should == {}
    

    Then the example will fail and RSpec will print the value of the error hash, and you can see which errors are actually being generated.

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

Sidebar

Related Questions

I'm using rspec with the email-spec gem. I'm trying to do: last_delivery = ActionMailer::Base.deliveries.last
I'm trying to test/spec the following action method public virtual ActionResult ChangePassword(ChangePasswordModel model) {
I'm trying to digest this statement in the C# spec, which states (§4.2): A
Just trying to do a simple view spec. When I first create this spec
I'm trying to write a request spec for a web page. This page works
I'm using rabl 0.6.13, rspec-rails 2.10.1, and rails 3.2.6. I'm trying to spec my
I'm trying to implement a request spec using Capybara, RSpec and JS (using Webkit).
I'm trying to make a spec file (rpm) for a insanely big software. The
I'm trying to find my way around the OAuth spec, its requirements and any
I am trying to use rspec on my rails application I run spec path/to/spec/spec.rb

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.