PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/plugins/acts_as_favorite/test/test_helper.rb

https://bitbucket.org/shiningray/youwenti
Ruby | 44 lines | 31 code | 10 blank | 3 comment | 2 complexity | 2749fb343b713545db5af6a62754d470 MD5 | raw file
Possible License(s): Apache-2.0
  1. $:.unshift(File.dirname(__FILE__) + '/../lib')
  2. require 'test/unit'
  3. require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
  4. require 'rubygems'
  5. require 'active_support/breakpoint'
  6. require 'active_record/fixtures'
  7. config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
  8. ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
  9. ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite'])
  10. load(File.dirname(__FILE__) + "/schema.rb")
  11. Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
  12. $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
  13. class Test::Unit::TestCase #:nodoc:
  14. def create_fixtures(*table_names)
  15. if block_given?
  16. Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
  17. else
  18. Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
  19. end
  20. end
  21. # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
  22. self.use_transactional_fixtures = true
  23. # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
  24. self.use_instantiated_fixtures = false
  25. # Add more helper methods to be used by all tests here...
  26. def assert_difference(object, method = nil, difference = 1)
  27. initial_value = object.send(method)
  28. yield
  29. assert_equal initial_value + difference, object.send(method), "#{object}##{method}"
  30. end
  31. def assert_no_difference(object, method, &block)
  32. assert_difference object, method, 0, &block
  33. end
  34. end