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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:48:05+00:00 2026-06-11T03:48:05+00:00

I’ve got a large rails test suite and I’m using Timecop just once. it

  • 0

I’ve got a large rails test suite and I’m using Timecop just once.

it "should not include votes from today" do
  assert_equal 8, @answer.todays_score
end

it "should include today's votes tomorrow" do
  Timecop.travel(Date.today + 1) do
    assert_equal 10, @answer.yesterdays_score
  end
end

These specs pass when I run the full suite with:

rake

or

rake spec

however Timecop.freeze doesn’t work if I try to run a smaller set or the individual spec. That is, both the following will fail:

rspec ./spec/models/answers_spec.rb

rake spec:models

Any ideas? Am I missing something about the interaction betwen ruby / rspec / rake and maybe bundler?. (for the record — I get the same results when I run all of the above preceded with ‘bundle execute’).

I’m including my Gemfile and spec.helper in case this clarifies anything.

Gemfile:

gem 'rails', '3.2.8'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'haml-rails'
gem 'sass'
gem 'chronic'
gem 'chronic_duration'
gem 'heroku'
gem 'pg', '0.13.1'
gem 'jquery-rails'
gem 'jquery_mobile_rails', "1.1.0"
gem "bcrypt-ruby", :require => "bcrypt"
gem 'rails_autolink'

group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'
  gem 'uglifier'
end

group :development, :test do
  gem 'timecop'
  gem 'ruby-prof' 
  gem 'factory_girl_rails'
  gem 'rspec-rails'  
  gem 'capybara'
  gem 'mocha'
end

spec_helper.rb:

require 'rubygems'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rails'
require 'rspec/autorun'
require 'mocha'

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  config.mock_with :mocha
  config.use_transactional_fixtures = true
  config.infer_base_class_for_anonymous_controllers = false
  config.include(MailerMacros)  
  config.before(:each) { reset_email }
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-06-11T03:48:07+00:00Added an answer on June 11, 2026 at 3:48 am

    I believe that if you try running rake spec enough times there will be times when it will fail. There is probably a time dependency problem somewhere that aggravates when the time gap between tests is smaller (just a hunch).

    My guess is that @answer has a time field which has been instantiated before it was called in the Timecop block. I think that you would have to create @answer within another Timecop.freeze block so that there is no second-guessing about @answer‘s time origins.

    Inspect your before blocks. (any before :all blocks?) I think that when running smaller test suites commands in the before block causes the object to be instantiated with the undesired timestamp before Timecop kicks in. If there is a before :all stuff from previous tests might have caused changes too.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.