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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:40:28+00:00 2026-06-09T07:40:28+00:00

I’m getting some weird validation behavior: it’s duplicating my validation error messages and I

  • 0

I’m getting some weird validation behavior: it’s duplicating my validation error messages and I can’t figure out what’s causing it… it doesn’t do this in the rails console.

Here is the validation from my Phone model:

# phone.rb
validates :number, :length => { :minimum => 3 }

My spec:

require 'spec_helper'

describe Phone do
  it "requires a number" do
    user = User.make!
    @p = Phone.new(number:nil,user_id:user.id,type:2)
    @p.valid?
    puts @p.errors.inspect 
    @p.should have(1).error_on(:number)
  end

My test results:

# rspec and machinist
#<ActiveModel::Errors:0x000000036f1258 @base=#<Phone id: nil, user_id: 614, kind: nil, number: nil, created_at: nil, updated_at: nil>, @messages={:number=>["is too short (minimum is 3 characters)", "is too short (minimum is 3 characters)"]}>
F

Failures:

  1) Phone requires a number
     Failure/Error: @p.should have(1).error_on(:number)
       expected 1 error on :number, got 2
     # ./spec/models/phone_spec.rb:11:in `block (2 levels) in <top (required)>'

Finished in 0.50988 seconds
1 example, 1 failure

As you can see, I’m getting “is too short (minimum is 3 characters)” twice… It’s also /only/ happening during testing.
Any ideas?

Thanks!

  • 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-09T07:40:31+00:00Added an answer on June 9, 2026 at 7:40 am

    The problem is in the line:

    Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f }
    

    in the spec_helper.rb file, in the Spork.each_run block

    If you change the method ‘load’ to ‘require’, it fixes the problem.

    Or if you have a recent enough version of Spork, you can remove the line altogether.
    I am pretty sure the error is caused when someone is installing a newer version Spork(0.9.0+) with old instructions, because the line:

    Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f }
    

    doesn’t even has to be stated explicitly in the spec_helper.rb file anymore. If it is then when the load method is used in the spec_helper.rb file, it reloads the files specified , most likely the cause of the strange RSpec duplicate validations errors.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't

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.