test_helper.rb 827 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ENV['RACK_ENV'] = 'test'
  2. require 'bundler/setup'
  3. Bundler.require :test
  4. $LOAD_PATH.unshift 'lib'
  5. require 'minitest/autorun'
  6. require 'minitest/pride'
  7. require 'active_support'
  8. require 'active_support/core_ext'
  9. require 'active_support/testing/assertions'
  10. require 'rr'
  11. Dir[File.dirname(__FILE__) + '/support/*.rb'].each do |file|
  12. autoload File.basename(file, '.rb').camelize, file
  13. end
  14. ActiveSupport::TestCase.test_order = :random
  15. class MiniTest::Spec
  16. include ActiveSupport::Testing::Assertions
  17. module DSL
  18. def context(*args, &block)
  19. describe(*args, &block)
  20. end
  21. end
  22. end
  23. def tmp_path
  24. $tmp_path ||= mk_tmp
  25. end
  26. def mk_tmp
  27. File.expand_path('../tmp', __FILE__).tap do |path|
  28. FileUtils.mkdir(path)
  29. end
  30. end
  31. def rm_tmp
  32. FileUtils.rm_rf $tmp_path if $tmp_path
  33. end
  34. Minitest.after_run do
  35. rm_tmp
  36. end