Sha256: 22f37244b658131b8065372aa68c140f308263364c4059cf752a9bacc0a27964

Contents?: true

Size: 878 Bytes

Versions: 4

Compression:

Stored size: 878 Bytes

Contents

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 %(#<Method: Kernel.URI>), 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 %(#<Method: URI.parse>), 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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
faraday-0.9.0.rc5 test/utils_test.rb
faraday-0.9.0.rc4 test/utils_test.rb
faraday-0.9.0.rc3 test/utils_test.rb
faraday-0.9.0.rc2 test/utils_test.rb