spec/spec_helper.rb in by_star-2.1.0.beta2 vs spec/spec_helper.rb in by_star-2.2.0.rc1

- old
+ new

@@ -1,35 +1,29 @@ -require 'rubygems' -require 'bundler' -Bundler.setup -require 'fileutils' -require 'logger' - -FileUtils.mkdir_p(File.dirname(__FILE__) + "/tmp") -$:.unshift(File.join(File.dirname(__FILE__), "../lib")) - -require 'active_record' -require 'mongoid' if Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3') -require 'active_support' -require 'active_support/core_ext/string/conversions' -require 'by_star' -require 'rspec' -require 'timecop' - - -# Define time zone before loading test_helper -zone = "UTC" -Time.zone = zone - -# Freeze time to Jan 1st of this year -Timecop.travel(Time.zone.local(Time.zone.now.year, 1, 1, 0, 0, 1, 0)) - -# Print the location of puts/p calls so you can find them later -# def puts str -# super caller.first if caller.first.index("shoulda.rb") == -1 -# super str -# end -# -# def p obj -# puts caller.first -# super obj -# end +require 'rubygems' +require 'bundler' +Bundler.setup +require 'fileutils' +require 'logger' + +FileUtils.mkdir_p(File.dirname(__FILE__) + "/tmp") +$:.unshift(File.join(File.dirname(__FILE__), "../lib")) + +require 'active_record' +require 'mongoid' +require 'chronic' +require 'timecop' +require 'by_star' + +# Specs should pass regardless of timezone +Time.zone = %w(Asia/Tokyo America/New_York Australia/Sydney UTC).sample +puts "Running specs in #{Time.zone} timezone..." + +# Set Rails time to 2014-01-01 00:00:00 +Timecop.travel(Time.zone.local(2014)) + +def testing_mongoid? + ENV['DB'] == 'mongodb' || ENV['DB'].nil? +end + +def testing_active_record? + ENV['DB'] != 'mongodb' +end