/activesupport/test/core_ext/load_error_test.rb

https://bitbucket.org/druly/rails_cherry_pick · Ruby · 32 lines · 30 code · 2 blank · 0 comment · 0 complexity · 2bb1f60dbfdde6c63bc82138049bd032 MD5 · raw file

  1. require 'abstract_unit'
  2. require 'active_support/core_ext/load_error'
  3. class TestMissingSourceFile < Test::Unit::TestCase
  4. def test_with_require
  5. assert_raise(MissingSourceFile) { require 'no_this_file_don\'t_exist' }
  6. end
  7. def test_with_load
  8. assert_raise(MissingSourceFile) { load 'nor_does_this_one' }
  9. end
  10. def test_path
  11. begin load 'nor/this/one.rb'
  12. rescue MissingSourceFile => e
  13. assert_equal 'nor/this/one.rb', e.path
  14. end
  15. end
  16. end
  17. class TestLoadError < Test::Unit::TestCase
  18. def test_with_require
  19. assert_raise(LoadError) { require 'no_this_file_don\'t_exist' }
  20. end
  21. def test_with_load
  22. assert_raise(LoadError) { load 'nor_does_this_one' }
  23. end
  24. def test_path
  25. begin load 'nor/this/one.rb'
  26. rescue LoadError => e
  27. assert_equal 'nor/this/one.rb', e.path
  28. end
  29. end
  30. end