hyperclient 0.9.1 → 1.0.1
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 +4 -4
- data/.rubocop.yml +3 -3
- data/.rubocop_todo.yml +12 -19
- data/.travis.yml +8 -9
- data/CHANGELOG.md +19 -0
- data/Gemfile +3 -1
- data/README.md +12 -6
- data/features/api_navigation.feature +5 -0
- data/features/steps/api_navigation.rb +16 -3
- data/features/steps/default_config.rb +2 -2
- data/features/support/api.rb +7 -1
- data/features/support/fixtures.rb +96 -2
- data/hyperclient.gemspec +0 -2
- data/lib/hyperclient/entry_point.rb +6 -5
- data/lib/hyperclient/link.rb +21 -0
- data/lib/hyperclient/link_collection.rb +3 -1
- data/lib/hyperclient/resource.rb +3 -1
- data/lib/hyperclient/resource_collection.rb +3 -1
- data/lib/hyperclient/version.rb +1 -1
- data/test/hyperclient/attributes_test.rb +9 -9
- data/test/hyperclient/collection_test.rb +15 -15
- data/test/hyperclient/curie_test.rb +4 -4
- data/test/hyperclient/entry_point_test.rb +44 -47
- data/test/hyperclient/link_collection_test.rb +14 -14
- data/test/hyperclient/link_test.rb +43 -43
- data/test/hyperclient/resource_collection_test.rb +6 -6
- data/test/hyperclient/resource_test.rb +26 -26
- data/test/hyperclient_test.rb +9 -10
- data/test/test_helper.rb +6 -2
- metadata +6 -37
- data/lib/faraday/connection.rb +0 -17
- data/test/faraday/connection_test.rb +0 -29
data/test/hyperclient_test.rb
CHANGED
@@ -20,23 +20,22 @@ describe Hyperclient do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'creates a Faraday connection with the default and additional headers' do
|
23
|
-
client.headers['Content-Type'].must_equal 'application/hal+json'
|
24
|
-
client.headers['Accept'].must_equal 'application/hal+json,application/json'
|
25
|
-
client.headers['Access-Token'].must_equal 'token'
|
23
|
+
_(client.headers['Content-Type']).must_equal 'application/hal+json'
|
24
|
+
_(client.headers['Accept']).must_equal 'application/hal+json,application/json'
|
25
|
+
_(client.headers['Access-Token']).must_equal 'token'
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'creates a Faraday connection with the entry point url' do
|
29
|
-
client.connection.url_prefix.to_s.must_equal 'http://api.example.org/'
|
29
|
+
_(client.connection.url_prefix.to_s).must_equal 'http://api.example.org/'
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'creates a Faraday connection with the default block plus any additional handlers' do
|
33
33
|
handlers = client.connection.builder.handlers
|
34
|
-
handlers.must_include Faraday::Request::OAuth
|
35
|
-
handlers.must_include Faraday::Response::RaiseError
|
36
|
-
handlers.must_include FaradayMiddleware::FollowRedirects
|
37
|
-
handlers.must_include FaradayMiddleware::EncodeHalJson
|
38
|
-
handlers.must_include FaradayMiddleware::ParseHalJson
|
39
|
-
handlers.must_include Faraday::Adapter::NetHttp
|
34
|
+
_(handlers).must_include Faraday::Request::OAuth
|
35
|
+
_(handlers).must_include Faraday::Response::RaiseError
|
36
|
+
_(handlers).must_include FaradayMiddleware::FollowRedirects
|
37
|
+
_(handlers).must_include FaradayMiddleware::EncodeHalJson
|
38
|
+
_(handlers).must_include FaradayMiddleware::ParseHalJson
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
data/test/test_helper.rb
CHANGED
@@ -2,12 +2,16 @@ $LOAD_PATH << 'lib'
|
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'minitest/pride'
|
5
|
-
require 'mocha/
|
5
|
+
require 'mocha/minitest'
|
6
6
|
require 'json'
|
7
7
|
|
8
8
|
MiniTest::Test.class_eval do
|
9
9
|
def stub_request(conn, adapter_class = Faraday::Adapter::Test, &stubs_block)
|
10
10
|
adapter_handler = conn.builder.handlers.find { |h| h.klass < Faraday::Adapter }
|
11
|
-
|
11
|
+
if adapter_handler
|
12
|
+
conn.builder.swap(adapter_handler, adapter_class, &stubs_block)
|
13
|
+
else
|
14
|
+
conn.builder.adapter adapter_class, &stubs_block
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oriol Gual
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: faraday-digestauth
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: faraday_hal_middleware
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +66,6 @@ dependencies:
|
|
80
66
|
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: net-http-digest_auth
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
69
|
description: Hyperclient is a Ruby Hypermedia API client.
|
98
70
|
email:
|
99
71
|
- oriol.gual@gmail.com
|
@@ -125,7 +97,6 @@ files:
|
|
125
97
|
- features/support/env.rb
|
126
98
|
- features/support/fixtures.rb
|
127
99
|
- hyperclient.gemspec
|
128
|
-
- lib/faraday/connection.rb
|
129
100
|
- lib/hyperclient.rb
|
130
101
|
- lib/hyperclient/attributes.rb
|
131
102
|
- lib/hyperclient/collection.rb
|
@@ -136,7 +107,6 @@ files:
|
|
136
107
|
- lib/hyperclient/resource.rb
|
137
108
|
- lib/hyperclient/resource_collection.rb
|
138
109
|
- lib/hyperclient/version.rb
|
139
|
-
- test/faraday/connection_test.rb
|
140
110
|
- test/fixtures/collection.json
|
141
111
|
- test/fixtures/element.json
|
142
112
|
- test/fixtures/root.json
|
@@ -153,7 +123,7 @@ files:
|
|
153
123
|
homepage: https://github.com/codegram/hyperclient/
|
154
124
|
licenses: []
|
155
125
|
metadata: {}
|
156
|
-
post_install_message:
|
126
|
+
post_install_message:
|
157
127
|
rdoc_options: []
|
158
128
|
require_paths:
|
159
129
|
- lib
|
@@ -168,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
138
|
- !ruby/object:Gem::Version
|
169
139
|
version: '0'
|
170
140
|
requirements: []
|
171
|
-
rubygems_version: 3.
|
172
|
-
signing_key:
|
141
|
+
rubygems_version: 3.1.3
|
142
|
+
signing_key:
|
173
143
|
specification_version: 4
|
174
144
|
summary: ''
|
175
145
|
test_files:
|
@@ -180,7 +150,6 @@ test_files:
|
|
180
150
|
- features/support/api.rb
|
181
151
|
- features/support/env.rb
|
182
152
|
- features/support/fixtures.rb
|
183
|
-
- test/faraday/connection_test.rb
|
184
153
|
- test/fixtures/collection.json
|
185
154
|
- test/fixtures/element.json
|
186
155
|
- test/fixtures/root.json
|
data/lib/faraday/connection.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'faraday/digestauth'
|
3
|
-
|
4
|
-
module Faraday
|
5
|
-
# Reopen Faraday::Connection to add a helper to set the digest auth data.
|
6
|
-
class Connection
|
7
|
-
# Public: Adds the digest auth middleware at the top and sets the user and
|
8
|
-
# password.
|
9
|
-
#
|
10
|
-
# user - A String with the user.
|
11
|
-
# password - A String with the password.
|
12
|
-
#
|
13
|
-
def digest_auth(user, password)
|
14
|
-
builder.insert(0, Faraday::Request::DigestAuth, user, password)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
require_relative '../../lib/faraday/connection'
|
3
|
-
|
4
|
-
module Faraday
|
5
|
-
describe Connection do
|
6
|
-
describe 'digest_auth' do
|
7
|
-
let(:connection) do
|
8
|
-
Faraday.new('http://api.example.org/') do |builder|
|
9
|
-
builder.request :url_encoded
|
10
|
-
builder.adapter :net_http
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'inserts the DigestAuth middleware at the top' do
|
15
|
-
connection.digest_auth('user', 'password')
|
16
|
-
|
17
|
-
connection.builder.handlers.first.klass.must_equal Faraday::Request::DigestAuth
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'passes the user and password to the middleware' do
|
21
|
-
connection.digest_auth('user', 'password')
|
22
|
-
|
23
|
-
Faraday::Request::DigestAuth.expects(:new).with(anything, 'user', 'password').returns(stub_everything)
|
24
|
-
|
25
|
-
connection.get('/')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|