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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:00:01+00:00 2026-05-11T20:00:01+00:00

I am writing my specs on my model Thing which has a date field

  • 0

I am writing my specs on my model Thing which has a date field which should be after the date of creation, thus I use the validate_timeliness plugin like that

validate_date :date, :after Time.now

I want to be able to add some Things with an anterior date but validation fails. I want to bypass the validation when creating some Things with the machinist factory.

Any clue ?

  • 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-11T20:00:01+00:00Added an answer on May 11, 2026 at 8:00 pm

    Shouldn’t your validation ensure that the date is after the created_at attribute?? Rather than Time.now???

    You shouldn’t be trying to use invalid data in your tests, what you probably should do instead is fudge the created at time.

    @thing = Thing.make(:created_at => 1.day.ago)
    

    The only reason to try and put a time in the past in your spec surely should be to test that the validation is indeed working ..

    @thing = Thing.make_unsaved(:date => 1.day.ago)
    @thing.should have(1).error_on(:date)
    

    Is there a reason why you want to do this? What are you trying to test??

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

Sidebar

Related Questions

I'm writing a curses script which requires cleanup after processing SIGINT in order to
I'm writing a program for others to use. One of the design specs is
I'm writing some specs that test the template files in a gem that has
I'm writing the spec for controller: it 'should call the method that performs the
I'm writing specs for different test cases for Jasmine and QUnit to compare them
I have been writing specs for controllers and models, but I have never written
In open source projects I see the following two ways of writing specs: Specs
I'm optimizing a PNG encoder for use within Flash SWFs (but I'm writing it
I am looking for good templates for writing both technical and functional specs on
OK, so instead of writing a whole bunch of access control specs, and duplicating

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.