Sha256: 869eb5559657b082d62694b2400063152dd2e76224f0e8f91c4317f40f379204

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/LineLength

require_relative '../test_helper'

module Excon
  class MiddlewareTest < Minitest::Test
    def setup
      Excon.defaults[:mock] = true
      Excon.stub(
        { :path => '/lowercase-content-type' },
        {
          headers: { 'content-type' => 'application/hal+json' },
          body:    '{}',
          status:  200
        }
      )
      Excon.stub(
        { :path => '/uppercase-content-type' },
        {
          headers: { 'Content-Type' => 'application/hal+json' },
          body:    '{}',
          status:  200
        }
      )
    end

    def test_request_with_lowercase_content_type
      test = Excon.get(
        'http://example.com',
        path: '/lowercase-content-type',
        middlewares: Excon.defaults[:middlewares] + [Excon::HyperMedia::Middleware]
      )

      assert test.data[:hypermedia]
    end

    def test_request_with_uppercase_content_type
      test = Excon.get(
        'http://example.com',
        path: '/uppercase-content-type',
        middlewares: Excon.defaults[:middlewares] + [Excon::HyperMedia::Middleware]
      )

      assert test.data[:hypermedia]
    end

    def teardown
      Excon.stubs.clear
      Excon.defaults[:mock] = false
    end
  end
end

# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/LineLength

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
excon-hypermedia-0.7.0 test/excon/middleware_test.rb