PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/plugins/friendly_id/test/test_helper.rb

https://github.com/technicalpickles/flockup
Ruby | 55 lines | 41 code | 13 blank | 1 comment | 2 complexity | d6be8ea2b8507f3a179962a611c1bf08 MD5 | raw file
Possible License(s): GPL-2.0
  1. $:.unshift(File.dirname(__FILE__) + '/../lib')
  2. ENV['RAILS_ENV'] = 'test'
  3. require 'test/unit'
  4. require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
  5. require 'active_record/fixtures'
  6. require 'action_controller/test_process'
  7. config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
  8. ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
  9. db_adapter = ENV['DB']
  10. # no db passed, try one of these fine config-free DBs before bombing.
  11. db_adapter ||=
  12. begin
  13. require 'rubygems'
  14. require 'sqlite3'
  15. 'sqlite3'
  16. rescue MissingSourceFile
  17. begin
  18. require 'sqlite'
  19. 'sqlite'
  20. rescue MissingSourceFile
  21. end
  22. end
  23. if db_adapter.nil?
  24. raise 'No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite3 or Sqlite.'
  25. end
  26. ActiveRecord::Base.establish_connection(config[db_adapter])
  27. load(File.dirname(__FILE__) + "/schema.rb")
  28. Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures"
  29. $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
  30. class Test::Unit::TestCase #:nodoc:
  31. include ActionController::TestProcess
  32. def create_fixtures(*table_names)
  33. if block_given?
  34. Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
  35. else
  36. Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
  37. end
  38. end
  39. self.use_transactional_fixtures = true
  40. self.use_instantiated_fixtures = false
  41. protected
  42. end