uri_test.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. require 'test_helper'
  2. require 'dav4rack/uri'
  3. class UriTest < Minitest::Test
  4. def test_should_parse_header_value_with_root_set
  5. d = DAV4Rack::Uri.new 'https://example.com/foo/bar', script_name: '/foo'
  6. assert_equal 'example.com', d.host
  7. assert_equal '/foo/bar', d.path
  8. assert_equal '/bar', d.path_info
  9. end
  10. def test_should_parse_and_unescape_header_value
  11. d = DAV4Rack::Uri.new 'https://example.com/fo%20o/bar'
  12. assert_equal 'example.com', d.host
  13. assert_equal '/fo o/bar', d.path
  14. assert_equal '/fo o/bar', d.path_info
  15. end
  16. def test_should_handle_wrong_script_name
  17. d = DAV4Rack::Uri.new 'https://example.com/foo/bar', script_name: '/other'
  18. assert_equal 'example.com', d.host
  19. assert_equal '/foo/bar', d.path
  20. assert_nil d.path_info
  21. end
  22. def test_should_parse_path
  23. d = DAV4Rack::Uri.new '/foo/bar', script_name: '/other'
  24. assert_nil d.host
  25. assert_equal '/foo/bar', d.path
  26. assert_nil d.path_info
  27. d = DAV4Rack::Uri.new '//foo/bar', script_name: '/foo'
  28. assert_nil d.host
  29. assert_equal '/foo/bar', d.path
  30. assert_equal '/bar', d.path_info
  31. end
  32. end