require File.expand_path('../helper', __FILE__) class TestUtils < Faraday::TestCase def setup @url = "http://example.com/abc" end def teardown Faraday::Utils.default_uri_parser = nil end def test_parses_with_default assert_equal %(#), Faraday::Utils.default_uri_parser.to_s uri = normalize(@url) assert_equal 'example.com', uri.host end def test_parses_with_URI Faraday::Utils.default_uri_parser = ::URI assert_equal %(#), Faraday::Utils.default_uri_parser.to_s uri = normalize(@url) assert_equal 'example.com', uri.host end def test_parses_with_block Faraday::Utils.default_uri_parser = lambda do |uri| "booya#{"!" * uri.size}" end assert_equal 'booya!!!!!!!!!!!!!!!!!!!!!!', normalize(@url) end def normalize(url) Faraday::Utils::URI(url) end end