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

  • Home
  • SEARCH
  • 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 7627107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:24:57+00:00 2026-05-31T05:24:57+00:00

I have a problem where I’m validating that the current time has been inserted

  • 0

I have a problem where I’m validating that the current time has been inserted into the html (used to do a sort of time_ago with javascript).

The current unix time (epoch) is rendered in the given html element’s data data attribute, in this case like this:

<a href="/somewhere" data-last-points-awarded-at="1331606458">Something Happend</a>

But when my test runs:

recipe = Factory(:recipe, name: "Apple Pie", user: @user)

visit some_path

time_in_layout = find('a[data-last-points-awarded-at]')['data-last-points-awarded-at']
current_time = Proc.new { Time.now }.call.to_i.to_s

time_in_layout.should eql(current_time)

Upon running my test it fails… but just barely:

Failure/Error: time_in_layout.should eql(current_time)

   expected: "1331606459"
        got: "1331606458"

   (compared using eql?)

Everything is fine, the test is pretty much the way I actually want it to work however, the proc returns a time which is a second later, how can I fix this? Like how can I lock the time at the beginning of the test, can I even do such a thing?

  • 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-31T05:24:58+00:00Added an answer on May 31, 2026 at 5:24 am

    Check out TimeCop, as it does exactly what you want.

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

Sidebar

Related Questions

I have problem in some JavaScript that I am writing where the Switch statement
I have problem with fancybox. I want to write a function that will run
I have problem adding markers into marker Clusterer of Google Maps. Firebug returns error:
I have a French site that I want to parse, but am running into
I have problem with Activities navigation, searching works good. Activities hierarchy looks like that:
I have problem running my app on Android 2.3 (Gingerbread). The app has a
I have problem with resized editText (I made him smaller, actually), he has 40dip
I have problem in determining time complexities of algorithms. for(int i=0;i <n i++){} O(n)
have problem with ampersand (&) How to search for the words (or sentences) that
I have problem to put several countdowns on page. I use HTML.Partial: <span><strong id=time_h></strong>godz.

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.