test_helper.rb 781 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. class MiniTest::Spec
  15. include ActiveSupport::Testing::Assertions
  16. module DSL
  17. def context(*args, &block)
  18. describe(*args, &block)
  19. end
  20. end
  21. end
  22. def tmp_path
  23. $tmp_path ||= mk_tmp
  24. end
  25. def mk_tmp
  26. File.expand_path('../tmp', __FILE__).tap do |path|
  27. FileUtils.mkdir(path)
  28. end
  29. end
  30. def rm_tmp
  31. FileUtils.rm_rf $tmp_path if $tmp_path
  32. end
  33. Minitest.after_run do
  34. rm_tmp
  35. end