Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:153546
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
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.