test_helper.rb 756 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/core_ext'
  8. require 'active_support/testing/assertions'
  9. require 'rr'
  10. Dir[File.dirname(__FILE__) + '/support/*.rb'].each do |file|
  11. autoload File.basename(file, '.rb').camelize, file
  12. end
  13. class MiniTest::Spec
  14. include ActiveSupport::Testing::Assertions
  15. module DSL
  16. def context(*args, &block)
  17. describe(*args, &block)
  18. end
  19. end
  20. end
  21. def tmp_path
  22. $tmp_path ||= mk_tmp
  23. end
  24. def mk_tmp
  25. File.expand_path('../tmp', __FILE__).tap do |path|
  26. FileUtils.mkdir(path)
  27. end
  28. end
  29. def rm_tmp
  30. FileUtils.rm_rf $tmp_path if $tmp_path
  31. end
  32. Minitest.after_run do
  33. rm_tmp
  34. end