excon-hypermedia 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 669bc2a498c87c5ad49049e6748d550769c991db
4
- data.tar.gz: 49120d1428699dabc3dcc2c096222bffcb880372
2
+ SHA256:
3
+ metadata.gz: e5194b922b1a5cfda77304bd8800408c6c4bf8c43fd43e94a61cc46c45370860
4
+ data.tar.gz: 50adb4314587f29da3120b62087afddbd850fb33d62f75d770b225f99c21d482
5
5
  SHA512:
6
- metadata.gz: 8d6d2fe1929f0817a262594cc6094e30f569de3630bcefc905ce2df56f093ebd224566db2ef2bebaff5e5627a9b497116a7c6305169bee64ea8d4a5baafd4730
7
- data.tar.gz: e5330746ac703d144ba260e18fe77e3d812244482c32f1eff557cca72709dd2962fdfe7b656ffb4731c7f1413706d7398e019c96a0be45a0e818f7e8326eb708
6
+ metadata.gz: 25688b9b666becd230dcc00c638e336a9b86eefcd13fd5f56e596b2040318a1786e14c8ed6115a3fc0645062a658758431b45dcb5bd5f46b8489ea45ee35af36
7
+ data.tar.gz: 177a1f114fa7696aff96cafdab91a433d3743369cd849182aeda3823329f0343f24398117a04219bf787a3cb881afb214ff2c07ed6950fa7b49e47bda4ece0d1
@@ -36,7 +36,9 @@ module Excon
36
36
  end
37
37
 
38
38
  def response_call(datum)
39
- return super unless (content_type = datum.dig(:response, :headers, 'Content-Type').to_s)
39
+ return super unless (headers = datum.dig(:response, :headers))
40
+ return super unless (match = headers.find { |k, v| k.downcase == 'content-type' })
41
+ content_type = match[1].to_s
40
42
 
41
43
  datum[:response][:hypermedia] = if datum[:hypermedia].nil?
42
44
  content_type.include?('hal+json')
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Excon
4
4
  module HyperMedia
5
- VERSION = '0.6.0'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/AbcSize
4
+ # rubocop:disable Metrics/LineLength
5
+
6
+ require_relative '../test_helper'
7
+
8
+ module Excon
9
+ class MiddlewareTest < Minitest::Test
10
+ def setup
11
+ Excon.defaults[:mock] = true
12
+ Excon.stub(
13
+ { :path => '/lowercase-content-type' },
14
+ {
15
+ headers: { 'content-type' => 'application/hal+json' },
16
+ body: '{}',
17
+ status: 200
18
+ }
19
+ )
20
+ Excon.stub(
21
+ { :path => '/uppercase-content-type' },
22
+ {
23
+ headers: { 'Content-Type' => 'application/hal+json' },
24
+ body: '{}',
25
+ status: 200
26
+ }
27
+ )
28
+ end
29
+
30
+ def test_request_with_lowercase_content_type
31
+ test = Excon.get(
32
+ 'http://example.com',
33
+ path: '/lowercase-content-type',
34
+ middlewares: Excon.defaults[:middlewares] + [Excon::HyperMedia::Middleware]
35
+ )
36
+
37
+ assert test.data[:hypermedia]
38
+ end
39
+
40
+ def test_request_with_uppercase_content_type
41
+ test = Excon.get(
42
+ 'http://example.com',
43
+ path: '/uppercase-content-type',
44
+ middlewares: Excon.defaults[:middlewares] + [Excon::HyperMedia::Middleware]
45
+ )
46
+
47
+ assert test.data[:hypermedia]
48
+ end
49
+
50
+ def teardown
51
+ Excon.stubs.clear
52
+ Excon.defaults[:mock] = false
53
+ end
54
+ end
55
+ end
56
+
57
+ # rubocop:enable Metrics/AbcSize
58
+ # rubocop:enable Metrics/LineLength
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excon-hypermedia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean
8
8
  - Mertz
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-01 00:00:00.000000000 Z
12
+ date: 2020-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -171,6 +171,7 @@ files:
171
171
  - test/excon/integration_test.rb
172
172
  - test/excon/link_object_test.rb
173
173
  - test/excon/links_test.rb
174
+ - test/excon/middleware_test.rb
174
175
  - test/excon/properties_test.rb
175
176
  - test/excon/resource_object_test.rb
176
177
  - test/excon/response_test.rb
@@ -181,7 +182,7 @@ homepage: https://github.com/JeanMertz/excon-hypermedia
181
182
  licenses:
182
183
  - MIT
183
184
  metadata: {}
184
- post_install_message:
185
+ post_install_message:
185
186
  rdoc_options: []
186
187
  require_paths:
187
188
  - lib
@@ -196,9 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
197
  - !ruby/object:Gem::Version
197
198
  version: '0'
198
199
  requirements: []
199
- rubyforge_project:
200
- rubygems_version: 2.6.13
201
- signing_key:
200
+ rubygems_version: 3.1.4
201
+ signing_key:
202
202
  specification_version: 4
203
203
  summary: Excon, with Hypermedia traversing baked in.
204
204
  test_files: []