PageRenderTime 56ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/plugins/acts_as_paranoid/test/test_helper.rb

https://bitbucket.org/shoebox639/bkmk-srv
Ruby | 47 lines | 33 code | 8 blank | 6 comment | 3 complexity | f97bb1be9962ac497cf0d9685677b90e MD5 | raw file
  1. $:.unshift(File.dirname(__FILE__) + '/../lib')
  2. require 'test/unit'
  3. require 'rubygems'
  4. if ENV['RAILS'].nil?
  5. require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
  6. else
  7. # specific rails version targeted
  8. # load activerecord and plugin manually
  9. gem 'activerecord', "=#{ENV['RAILS']}"
  10. require 'active_record'
  11. $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
  12. Dir["#{$LOAD_PATH.last}/**/*.rb"].each do |path|
  13. require path[$LOAD_PATH.last.size + 1..-1]
  14. end
  15. require File.join(File.dirname(__FILE__), '..', 'init.rb')
  16. end
  17. require 'active_record/fixtures'
  18. config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
  19. # do this so fixtures will load
  20. ActiveRecord::Base.configurations.update config
  21. ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
  22. ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite3'])
  23. load(File.dirname(__FILE__) + "/schema.rb")
  24. Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
  25. $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
  26. class Test::Unit::TestCase #:nodoc:
  27. def create_fixtures(*table_names)
  28. if block_given?
  29. Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
  30. else
  31. Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
  32. end
  33. end
  34. # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
  35. self.use_transactional_fixtures = true
  36. # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
  37. self.use_instantiated_fixtures = false
  38. # Add more helper methods to be used by all tests here...
  39. end