Skip to content

@ffmike /gist:153546
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ENV["RAILS_ENV"] = "test" if ENV["RAILS_ENV"].nil? || ENV["RAILS_ENV"] == ''
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require 'shoulda'
require 'mocha'
require 'authlogic/test_case'
# skip after_create callback during testing
# class Company < ActiveRecord::Base; def setup_default_categories; end; end
class ActiveSupport::TestCase
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
#fixtures :all
# Add more helper methods to be used by all tests here...
end
class ActionController::TestCase
setup :activate_authlogic
end
if !Time.respond_to?(:real_now) # assures there is no infinite looping when aliasing #now
Time.class_eval do
class << self
attr_accessor :testing_offset
alias_method :real_now, :now
def now
real_now - testing_offset
end
alias_method :new, :now
end
end
end
Time.testing_offset = 0
module Test # :nodoc:
module Unit # :nodoc:
class TestCase
##
# Time warp to the specified time for the duration of the passed block.
def pretend_now_is(*args)
begin
Time.testing_offset = Time.now - time_from(*args)
yield
ensure
Time.testing_offset = 0
end
end
private
def time_from(*args)
return args[0] if 1 == args.size && args[0].is_a?(Time)
Time.utc(*args)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.