excon-hypermedia 0.4.1 → 0.4.2

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
2
  SHA1:
3
- metadata.gz: 4ac864a15335585a7b84fcee3def970232abe429
4
- data.tar.gz: 53aaadb46648675e6d2d919fdadda891aee9f106
3
+ metadata.gz: 29b47d541b2f707b73bc69d61e0cc0a4682104c2
4
+ data.tar.gz: fd216f256e5b926307bdb4dd59dd58774a3a2753
5
5
  SHA512:
6
- metadata.gz: 6806fc02216a5c3ad4d73db1b3d0e6f049a3841ac7d3d3113cc14f65a3a8210b3746fb724c870625fe69322fc119a0906893a361361c8d3964132f69e7f62bf1
7
- data.tar.gz: bf537f951a42146063a8be8c8edeaa535ea65f4ce4e7f5d46d08a61bed43475ba53ab7e1113eb4b121b820d04acb1643bc258709b49a008c0ae6a38f7d7cf5ae
6
+ metadata.gz: 85536ac1d03e1179c50c66de11085db9b6004e19a951896d01cf8fab7661d78188668e5ba6a116466d3161c54e2132e0f421a14f437c41cf2c8cfdb6d10a41f4
7
+ data.tar.gz: 36eeaa8528105c6dd4d1614fed06a56e782e485238055890c123a21d010acd3d80eaa9996e0a59c011d2846cd8e60037142d00476952ef92a93d167ff4baccca
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # coding: utf-8
2
+ # encoding: utf-8
3
3
  lib = File.expand_path('../lib', __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'excon/hypermedia/version'
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'm', '~> 1.5'
26
26
 
27
27
  spec.add_dependency 'excon', '~> 0.49'
28
- spec.add_dependency 'excon-addressable', '~> 0.2'
28
+ spec.add_dependency 'excon-addressable', '~> 0.3'
29
29
  end
@@ -37,7 +37,7 @@ module Excon
37
37
  end
38
38
 
39
39
  def body_to_hash
40
- content_type.include?('application/hal+json') ? JSON.parse(response.body) : {}
40
+ (content_type =~ %r{application/(hal\+)?json}).nil? ? {} : JSON.parse(response.body)
41
41
  end
42
42
 
43
43
  def content_type
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Excon
4
4
  module HyperMedia
5
- VERSION = '0.4.1'
5
+ VERSION = '0.4.2'
6
6
  end
7
7
  end
@@ -92,6 +92,13 @@ module Excon
92
92
  assert_equal data(:front_wheel)['position'], response.resource._embedded.wheels.first.position
93
93
  end
94
94
 
95
+ def test_request_with_json_content_type
96
+ api = Excon.get('https://www.example.org/api_v2.json', hypermedia: true)
97
+ response = api.rel('product', expand: { uid: 'bicycle' }).get
98
+
99
+ assert response.body.include?('https://www.example.org/product/bicycle')
100
+ end
101
+
95
102
  def teardown
96
103
  Excon.stubs.clear
97
104
  end
data/test/test_helper.rb CHANGED
@@ -23,6 +23,7 @@ module Excon
23
23
  Excon.stub({ method: :get, path: '/product/bicycle/wheels/rear' }, response.merge(body: rear_wheel_body))
24
24
  Excon.stub({ method: :get, path: '/product/pump' }, response.merge(body: pump_body))
25
25
  Excon.stub({ method: :get, path: '/product/handlebar' }, response.merge(body: handlebar_body))
26
+ Excon.stub({ method: :get, path: '/api_v2.json' }, body: api_body, headers: { 'Content-Type' => 'application/json' })
26
27
  end
27
28
 
28
29
  def teardown
@@ -92,7 +93,9 @@ module Excon
92
93
  <<~EOF
93
94
  {
94
95
  "_links": {
95
- "self": "https://www.example.org/product/handlebar"
96
+ "self": {
97
+ "href": "https://www.example.org/product/handlebar"
98
+ }
96
99
  },
97
100
  "material": "Carbon fiber",
98
101
  "reach": "75mm",
@@ -105,7 +108,9 @@ module Excon
105
108
  <<~EOF
106
109
  {
107
110
  "_links": {
108
- "self": "https://www.example.org/product/pump"
111
+ "self": {
112
+ "href": "https://www.example.org/product/pump"
113
+ }
109
114
  },
110
115
  "weight": "2kg",
111
116
  "type": "Floor Pump",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excon-hypermedia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-21 00:00:00.000000000 Z
12
+ date: 2016-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -115,14 +115,14 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '0.2'
118
+ version: '0.3'
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '0.2'
125
+ version: '0.3'
126
126
  description: Excon, with Hypermedia traversing baked in.
127
127
  email:
128
128
  - jean@mertz.fm
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.5.1
179
+ rubygems_version: 2.6.4
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Excon, with Hypermedia traversing baked in.