hyperclient 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +55 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +33 -10
- data/CONTRIBUTING.md +117 -0
- data/Gemfile +2 -1
- data/Guardfile +6 -6
- data/LICENSE +2 -2
- data/README.md +138 -0
- data/Rakefile +5 -3
- data/UPGRADING.md +37 -0
- data/examples/splines_api.rb +22 -0
- data/features/steps/api_navigation.rb +8 -8
- data/features/steps/default_config.rb +6 -6
- data/features/support/api.rb +4 -4
- data/features/support/fixtures.rb +1 -1
- data/hyperclient.gemspec +9 -8
- data/lib/faraday/connection.rb +2 -2
- data/lib/hyperclient.rb +1 -1
- data/lib/hyperclient/attributes.rb +1 -1
- data/lib/hyperclient/collection.rb +3 -3
- data/lib/hyperclient/curie.rb +49 -0
- data/lib/hyperclient/entry_point.rb +6 -4
- data/lib/hyperclient/link.rb +70 -58
- data/lib/hyperclient/link_collection.rb +36 -11
- data/lib/hyperclient/resource.rb +49 -18
- data/lib/hyperclient/resource_collection.rb +2 -1
- data/lib/hyperclient/version.rb +1 -1
- data/test/fixtures/element.json +12 -1
- data/test/hyperclient/attributes_test.rb +2 -2
- data/test/hyperclient/collection_test.rb +6 -7
- data/test/hyperclient/curie_test.rb +34 -0
- data/test/hyperclient/entry_point_test.rb +3 -2
- data/test/hyperclient/link_collection_test.rb +26 -5
- data/test/hyperclient/link_test.rb +111 -86
- data/test/hyperclient/resource_collection_test.rb +2 -2
- data/test/hyperclient/resource_test.rb +67 -30
- data/test/test_helper.rb +2 -2
- metadata +54 -39
- data/Gemfile.lock +0 -112
- data/MIT-LICENSE +0 -20
- data/Readme.md +0 -180
- data/examples/cyberscore.rb +0 -76
- data/examples/hal_shop.rb +0 -53
- data/lib/faraday/request/digest_authentication.rb +0 -85
- data/test/faraday/digest_authentication_test.rb +0 -41
@@ -1,41 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
require 'faraday/request/digest_authentication'
|
3
|
-
|
4
|
-
module Faraday
|
5
|
-
describe Request::DigestAuth do
|
6
|
-
let(:connection) do
|
7
|
-
Faraday.new('http://api.example.org/') do |builder|
|
8
|
-
builder.request :digest, 'USER', 'PASS'
|
9
|
-
builder.adapter :net_http
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'when the server does not return a 401' do
|
14
|
-
it 'does nothing' do
|
15
|
-
stub_request(:get, 'http://api.example.org/productions/1').
|
16
|
-
to_return(status: 500, body: 'Foo body')
|
17
|
-
|
18
|
-
response = connection.get('/productions/1')
|
19
|
-
response.body.must_equal 'Foo body'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'when the server returns a 401' do
|
24
|
-
let(:first_call_headers) { 'Digest realm="MyApp", algorithm=MD5' }
|
25
|
-
let(:second_call_headers) { 'Digest username="USER", realm="MyApp", uri="/", algorithm="MD5"' }
|
26
|
-
it 'authenticates using digest' do
|
27
|
-
stub_request(:get, 'http://api.example.org/productions/1').
|
28
|
-
with(body: nil).
|
29
|
-
to_return(status: 401, headers: {'www-authenticate' => first_call_headers})
|
30
|
-
|
31
|
-
stub_request(:get, 'http://api.example.org/productions/1').
|
32
|
-
with(body: "{\"foo\":1}",
|
33
|
-
headers: {'Authorization' => %r{second_call_headers}}).
|
34
|
-
to_return(body: '{"resource": "This is the resource"}',
|
35
|
-
headers: {content_type: 'application/json'})
|
36
|
-
|
37
|
-
connection.get('/productions/1')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|