hyperclient 0.9.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,19 +12,19 @@ module Hyperclient
12
12
  end
13
13
 
14
14
  it 'exposes the collection as methods' do
15
- collection.title.must_equal 'Real World ASP.NET MVC3'
16
- collection.description.must_match(/production/)
17
- collection.permitted.must_equal true
15
+ _(collection.title).must_equal 'Real World ASP.NET MVC3'
16
+ _(collection.description).must_match(/production/)
17
+ _(collection.permitted).must_equal true
18
18
  end
19
19
 
20
20
  it 'exposes collection as a hash' do
21
- collection['title'].must_equal 'Real World ASP.NET MVC3'
22
- collection['description'].must_match(/production/)
23
- collection['permitted'].must_equal true
21
+ _(collection['title']).must_equal 'Real World ASP.NET MVC3'
22
+ _(collection['description']).must_match(/production/)
23
+ _(collection['permitted']).must_equal true
24
24
  end
25
25
 
26
26
  it 'correctly responds to methods' do
27
- collection.must_respond_to :title
27
+ _(collection).must_respond_to :title
28
28
  end
29
29
 
30
30
  it 'acts as enumerable' do
@@ -32,41 +32,41 @@ module Hyperclient
32
32
  name
33
33
  end
34
34
 
35
- names.must_equal %w[_links title description permitted _hidden_attribute _embedded]
35
+ _(names).must_equal %w[_links title description permitted _hidden_attribute _embedded]
36
36
  end
37
37
 
38
38
  describe '#to_hash' do
39
39
  it 'returns the wrapped collection as a hash' do
40
- collection.to_hash.must_be_kind_of Hash
40
+ _(collection.to_hash).must_be_kind_of Hash
41
41
  end
42
42
  end
43
43
 
44
44
  describe 'include?' do
45
45
  it 'returns true for keys that exist' do
46
- collection.include?('_links').must_equal true
46
+ _(collection.include?('_links')).must_equal true
47
47
  end
48
48
 
49
49
  it 'returns false for missing keys' do
50
- collection.include?('missing key').must_equal false
50
+ _(collection.include?('missing key')).must_equal false
51
51
  end
52
52
  end
53
53
 
54
54
  describe '#fetch' do
55
55
  it 'returns the value for keys that exist' do
56
- collection.fetch('title').must_equal 'Real World ASP.NET MVC3'
56
+ _(collection.fetch('title')).must_equal 'Real World ASP.NET MVC3'
57
57
  end
58
58
 
59
59
  it 'raises an error for missing keys' do
60
- proc { collection.fetch('missing key') }.must_raise KeyError
60
+ _(proc { collection.fetch('missing key') }).must_raise KeyError
61
61
  end
62
62
 
63
63
  describe 'with a default value' do
64
64
  it 'returns the value for keys that exist' do
65
- collection.fetch('title', 'default').must_equal 'Real World ASP.NET MVC3'
65
+ _(collection.fetch('title', 'default')).must_equal 'Real World ASP.NET MVC3'
66
66
  end
67
67
 
68
68
  it 'returns the default value for missing keys' do
69
- collection.fetch('missing key', 'default').must_equal 'default'
69
+ _(collection.fetch('missing key', 'default')).must_equal 'default'
70
70
  end
71
71
  end
72
72
  end
@@ -11,13 +11,13 @@ module Hyperclient
11
11
  it 'returns true if the curie is templated' do
12
12
  curie = Curie.new({ 'name' => 'image', 'templated' => true }, entry_point)
13
13
 
14
- curie.templated?.must_equal true
14
+ _(curie.templated?).must_equal true
15
15
  end
16
16
 
17
17
  it 'returns false if the curie is not templated' do
18
18
  curie = Curie.new({ 'name' => 'image' }, entry_point)
19
19
 
20
- curie.templated?.must_equal false
20
+ _(curie.templated?).must_equal false
21
21
  end
22
22
  end
23
23
 
@@ -26,12 +26,12 @@ module Hyperclient
26
26
  end
27
27
  describe '_name' do
28
28
  it 'returns curie name' do
29
- curie.name.must_equal 'image'
29
+ _(curie.name).must_equal 'image'
30
30
  end
31
31
  end
32
32
  describe 'expand' do
33
33
  it 'expands link' do
34
- curie.expand('thumbnail').must_equal '/images/thumbnail'
34
+ _(curie.expand('thumbnail')).must_equal '/images/thumbnail'
35
35
  end
36
36
  end
37
37
  end
@@ -10,60 +10,52 @@ module Hyperclient
10
10
 
11
11
  describe 'connection' do
12
12
  it 'creates a Faraday connection with the entry point url' do
13
- entry_point.connection.url_prefix.to_s.must_equal 'http://my.api.org/'
13
+ _(entry_point.connection.url_prefix.to_s).must_equal 'http://my.api.org/'
14
14
  end
15
15
 
16
16
  it 'creates a Faraday connection with the default headers' do
17
- entry_point.headers['Content-Type'].must_equal 'application/hal+json'
18
- entry_point.headers['Accept'].must_equal 'application/hal+json,application/json'
17
+ _(entry_point.headers['Content-Type']).must_equal 'application/hal+json'
18
+ _(entry_point.headers['Accept']).must_equal 'application/hal+json,application/json'
19
19
  end
20
20
 
21
21
  it 'can update headers after a connection has been constructed' do
22
- entry_point.connection.must_be_kind_of Faraday::Connection
22
+ _(entry_point.connection).must_be_kind_of Faraday::Connection
23
23
  entry_point.headers.update('Content-Type' => 'application/foobar')
24
- entry_point.headers['Content-Type'].must_equal 'application/foobar'
24
+ _(entry_point.headers['Content-Type']).must_equal 'application/foobar'
25
25
  end
26
26
 
27
27
  it 'can insert additional middleware after a connection has been constructed' do
28
- entry_point.connection.must_be_kind_of Faraday::Connection
29
-
30
- warning = 'WARNING: Unexpected middleware set after the adapter. ' \
31
- "This won't be supported from Faraday 1.0.\n"
32
-
33
- assert_output nil, warning do
34
- entry_point.connection.use :instrumentation
35
- end
36
-
28
+ _(entry_point.connection).must_be_kind_of Faraday::Connection
29
+ entry_point.connection.use :instrumentation
37
30
  handlers = entry_point.connection.builder.handlers
38
- handlers.must_include FaradayMiddleware::Instrumentation
31
+ _(handlers).must_include FaradayMiddleware::Instrumentation
39
32
  end
40
33
 
41
34
  it 'creates a Faraday connection with the default block' do
42
35
  handlers = entry_point.connection.builder.handlers
43
36
 
44
- handlers.must_include Faraday::Response::RaiseError
45
- handlers.must_include FaradayMiddleware::FollowRedirects
46
- handlers.must_include FaradayMiddleware::EncodeHalJson
47
- handlers.must_include FaradayMiddleware::ParseHalJson
48
- handlers.must_include Faraday::Adapter::NetHttp
37
+ _(handlers).must_include Faraday::Response::RaiseError
38
+ _(handlers).must_include FaradayMiddleware::FollowRedirects
39
+ _(handlers).must_include FaradayMiddleware::EncodeHalJson
40
+ _(handlers).must_include FaradayMiddleware::ParseHalJson
49
41
 
50
- entry_point.connection.options.params_encoder.must_equal Faraday::FlatParamsEncoder
42
+ _(entry_point.connection.options.params_encoder).must_equal Faraday::FlatParamsEncoder
51
43
  end
52
44
 
53
45
  it 'raises a ConnectionAlreadyInitializedError if attempting to modify headers' do
54
- entry_point.connection.must_be_kind_of Faraday::Connection
55
- -> { entry_point.headers = {} }.must_raise ConnectionAlreadyInitializedError
46
+ _(entry_point.connection).must_be_kind_of Faraday::Connection
47
+ _(-> { entry_point.headers = {} }).must_raise ConnectionAlreadyInitializedError
56
48
  end
57
49
 
58
50
  it 'raises a ConnectionAlreadyInitializedError if attempting to modify the faraday block' do
59
- entry_point.connection.must_be_kind_of Faraday::Connection
60
- -> { entry_point.connection {} }.must_raise ConnectionAlreadyInitializedError
51
+ _(entry_point.connection).must_be_kind_of Faraday::Connection
52
+ _(-> { entry_point.connection {} }).must_raise ConnectionAlreadyInitializedError
61
53
  end
62
54
  end
63
55
 
64
56
  describe 'initialize' do
65
57
  it 'sets a Link with the entry point url' do
66
- entry_point._url.must_equal 'http://my.api.org'
58
+ _(entry_point._url).must_equal 'http://my.api.org'
67
59
  end
68
60
  end
69
61
  end
@@ -77,17 +69,17 @@ module Hyperclient
77
69
 
78
70
  describe 'connection' do
79
71
  it 'creates a Faraday connection with the entry point url' do
80
- entry_point.connection.url_prefix.to_s.must_equal 'http://my.api.org/'
72
+ _(entry_point.connection.url_prefix.to_s).must_equal 'http://my.api.org/'
81
73
  end
82
74
 
83
75
  it 'creates a Faraday connection with the default headers' do
84
- entry_point.headers['Content-Type'].must_equal 'application/hal+json'
85
- entry_point.headers['Accept'].must_equal 'application/hal+json,application/json'
76
+ _(entry_point.headers['Content-Type']).must_equal 'application/hal+json'
77
+ _(entry_point.headers['Accept']).must_equal 'application/hal+json,application/json'
86
78
  end
87
79
 
88
80
  it 'creates a Faraday connection with options' do
89
- entry_point.connection.proxy.must_be_kind_of Faraday::ProxyOptions
90
- entry_point.connection.proxy.uri.to_s.must_equal 'http://my.proxy:8080'
81
+ _(entry_point.connection.proxy).must_be_kind_of Faraday::ProxyOptions
82
+ _(entry_point.connection.proxy.uri.to_s).must_equal 'http://my.proxy:8080'
91
83
  end
92
84
  end
93
85
  end
@@ -101,17 +93,17 @@ module Hyperclient
101
93
 
102
94
  describe 'connection' do
103
95
  it 'creates a Faraday connection with the entry point url' do
104
- entry_point.connection.url_prefix.to_s.must_equal 'http://my.api.org/'
96
+ _(entry_point.connection.url_prefix.to_s).must_equal 'http://my.api.org/'
105
97
  end
106
98
 
107
99
  it 'creates a Faraday connection with the default headers' do
108
- entry_point.headers['Content-Type'].must_equal 'application/hal+json'
109
- entry_point.headers['Accept'].must_equal 'application/hal+json,application/json'
100
+ _(entry_point.headers['Content-Type']).must_equal 'application/hal+json'
101
+ _(entry_point.headers['Accept']).must_equal 'application/hal+json,application/json'
110
102
  end
111
103
 
112
104
  it 'creates a Faraday connection with options' do
113
- entry_point.connection.proxy.must_be_kind_of Faraday::ProxyOptions
114
- entry_point.connection.proxy.uri.to_s.must_equal 'http://my.proxy:8080'
105
+ _(entry_point.connection.proxy).must_be_kind_of Faraday::ProxyOptions
106
+ _(entry_point.connection.proxy.uri.to_s).must_equal 'http://my.proxy:8080'
115
107
  end
116
108
  end
117
109
  end
@@ -134,21 +126,20 @@ module Hyperclient
134
126
 
135
127
  describe 'connection' do
136
128
  it 'creates a Faraday connection with the entry point url' do
137
- entry_point.connection.url_prefix.to_s.must_equal 'http://my.api.org/'
129
+ _(entry_point.connection.url_prefix.to_s).must_equal 'http://my.api.org/'
138
130
  end
139
131
 
140
132
  it 'creates a Faraday connection with non-default headers' do
141
- entry_point.headers['Content-Type'].must_equal 'application/foobar'
142
- entry_point.headers['Accept'].must_equal 'application/foobar'
133
+ _(entry_point.headers['Content-Type']).must_equal 'application/foobar'
134
+ _(entry_point.headers['Accept']).must_equal 'application/foobar'
143
135
  end
144
136
 
145
137
  it 'creates a Faraday connection with the default block' do
146
138
  handlers = entry_point.connection.builder.handlers
147
- handlers.wont_include Faraday::Response::RaiseError
148
- handlers.wont_include FaradayMiddleware::FollowRedirects
149
- handlers.must_include FaradayMiddleware::EncodeJson
150
- handlers.must_include FaradayMiddleware::ParseJson
151
- handlers.must_include Faraday::Adapter::NetHttp
139
+ _(handlers).wont_include Faraday::Response::RaiseError
140
+ _(handlers).wont_include FaradayMiddleware::FollowRedirects
141
+ _(handlers).must_include FaradayMiddleware::EncodeJson
142
+ _(handlers).must_include FaradayMiddleware::ParseJson
152
143
  end
153
144
  end
154
145
  end
@@ -165,26 +156,25 @@ module Hyperclient
165
156
 
166
157
  describe 'connection' do
167
158
  it 'creates a Faraday connection with the default and additional headers' do
168
- entry_point.headers['Content-Type'].must_equal 'application/hal+json'
169
- entry_point.headers['Accept'].must_equal 'application/hal+json,application/json'
170
- entry_point.headers['Access-Token'].must_equal 'token'
159
+ _(entry_point.headers['Content-Type']).must_equal 'application/hal+json'
160
+ _(entry_point.headers['Accept']).must_equal 'application/hal+json,application/json'
161
+ _(entry_point.headers['Access-Token']).must_equal 'token'
171
162
  end
172
163
 
173
164
  it 'creates a Faraday connection with the entry point url' do
174
- entry_point.connection.url_prefix.to_s.must_equal 'http://my.api.org/'
165
+ _(entry_point.connection.url_prefix.to_s).must_equal 'http://my.api.org/'
175
166
  end
176
167
 
177
168
  it 'creates a Faraday connection with the default block plus any additional handlers' do
178
169
  handlers = entry_point.connection.builder.handlers
179
170
 
180
- handlers.must_include Faraday::Request::OAuth
181
- handlers.must_include Faraday::Response::RaiseError
182
- handlers.must_include FaradayMiddleware::FollowRedirects
183
- handlers.must_include FaradayMiddleware::EncodeHalJson
184
- handlers.must_include FaradayMiddleware::ParseHalJson
185
- handlers.must_include Faraday::Adapter::NetHttp
171
+ _(handlers).must_include Faraday::Request::OAuth
172
+ _(handlers).must_include Faraday::Response::RaiseError
173
+ _(handlers).must_include FaradayMiddleware::FollowRedirects
174
+ _(handlers).must_include FaradayMiddleware::EncodeHalJson
175
+ _(handlers).must_include FaradayMiddleware::ParseHalJson
186
176
 
187
- entry_point.connection.options.params_encoder.must_equal Faraday::FlatParamsEncoder
177
+ _(entry_point.connection.options.params_encoder).must_equal Faraday::FlatParamsEncoder
188
178
  end
189
179
  end
190
180
  end
@@ -14,33 +14,33 @@ module Hyperclient
14
14
  end
15
15
 
16
16
  it 'is a collection' do
17
- LinkCollection.ancestors.must_include Collection
17
+ _(LinkCollection.ancestors).must_include Collection
18
18
  end
19
19
 
20
20
  it 'initializes the collection with links' do
21
- links.must_respond_to :search
22
- links.must_respond_to :gizmos
21
+ _(links).must_respond_to :search
22
+ _(links).must_respond_to :gizmos
23
23
  end
24
24
 
25
25
  it 'returns link objects for each link' do
26
- links.search.must_be_kind_of Link
27
- links['self'].must_be_kind_of Link
26
+ _(links.search).must_be_kind_of Link
27
+ _(links['self']).must_be_kind_of Link
28
28
 
29
- links.gizmos.must_be_kind_of Array
30
- links['gizmos'].must_be_kind_of Array
29
+ _(links.gizmos).must_be_kind_of Array
30
+ _(links['gizmos']).must_be_kind_of Array
31
31
  end
32
32
 
33
33
  describe 'plain link' do
34
34
  let(:plain_link) { links.self }
35
35
  it 'must be correct' do
36
- plain_link._url.must_equal '/productions/1'
36
+ _(plain_link._url).must_equal '/productions/1'
37
37
  end
38
38
  end
39
39
 
40
40
  describe 'templated link' do
41
41
  let(:templated_link) { links.search }
42
42
  it 'must expand' do
43
- templated_link._expand(search: 'gizmos')._url.must_equal '/productions/1?categories=gizmos'
43
+ _(templated_link._expand(search: 'gizmos')._url).must_equal '/productions/1?categories=gizmos'
44
44
  end
45
45
  end
46
46
 
@@ -48,10 +48,10 @@ module Hyperclient
48
48
  let(:curied_link) { links['image:thumbnail'] }
49
49
  let(:curie) { links._curies['image'] }
50
50
  it 'must expand' do
51
- curied_link._expand(version: 'small')._url.must_equal '/images/thumbnails/small.jpg'
51
+ _(curied_link._expand(version: 'small')._url).must_equal '/images/thumbnails/small.jpg'
52
52
  end
53
53
  it 'exposes curie' do
54
- curie.expand('thumbnail').must_equal '/docs/images/thumbnail'
54
+ _(curie.expand('thumbnail')).must_equal '/docs/images/thumbnail'
55
55
  end
56
56
  end
57
57
 
@@ -59,12 +59,12 @@ module Hyperclient
59
59
  let(:gizmos) { links.gizmos }
60
60
 
61
61
  it 'should have 2 items' do
62
- gizmos.length.must_equal 2
62
+ _(gizmos.length).must_equal 2
63
63
  end
64
64
 
65
65
  it 'must be an array of Links' do
66
66
  gizmos.each do |link|
67
- link.must_be_kind_of Link
67
+ _(link).must_be_kind_of Link
68
68
  end
69
69
  end
70
70
  end
@@ -72,7 +72,7 @@ module Hyperclient
72
72
  describe 'null link value' do
73
73
  let(:null_link) { links.null_link }
74
74
  it 'must be nil' do
75
- null_link.must_be_nil
75
+ _(null_link).must_be_nil
76
76
  end
77
77
  end
78
78
  end
@@ -11,12 +11,12 @@ module Hyperclient
11
11
  describe prop do
12
12
  it 'returns the property value' do
13
13
  link = Link.new('key', { prop => 'value' }, entry_point)
14
- link.send("_#{prop}").must_equal 'value'
14
+ _(link.send("_#{prop}")).must_equal 'value'
15
15
  end
16
16
 
17
17
  it 'returns nil if the property is not present' do
18
18
  link = Link.new('key', {}, entry_point)
19
- link.send("_#{prop}").must_be_nil
19
+ _(link.send("_#{prop}")).must_be_nil
20
20
  end
21
21
  end
22
22
  end
@@ -25,13 +25,13 @@ module Hyperclient
25
25
  it 'returns true if the link is templated' do
26
26
  link = Link.new('key', { 'templated' => true }, entry_point)
27
27
 
28
- link._templated?.must_equal true
28
+ _(link._templated?).must_equal true
29
29
  end
30
30
 
31
31
  it 'returns false if the link is not templated' do
32
32
  link = Link.new('key', {}, entry_point)
33
33
 
34
- link._templated?.must_equal false
34
+ _(link._templated?).must_equal false
35
35
  end
36
36
  end
37
37
 
@@ -39,13 +39,13 @@ module Hyperclient
39
39
  it 'returns a list of required variables' do
40
40
  link = Link.new('key', { 'href' => '/orders{?id,owner}', 'templated' => true }, entry_point)
41
41
 
42
- link._variables.must_equal %w[id owner]
42
+ _(link._variables).must_equal %w[id owner]
43
43
  end
44
44
 
45
45
  it 'returns an empty array for untemplated links' do
46
46
  link = Link.new('key', { 'href' => '/orders' }, entry_point)
47
47
 
48
- link._variables.must_equal []
48
+ _(link._variables).must_equal []
49
49
  end
50
50
  end
51
51
 
@@ -53,41 +53,41 @@ module Hyperclient
53
53
  describe 'required argument' do
54
54
  it 'builds a Link with the templated URI representation' do
55
55
  link = Link.new('key', { 'href' => '/orders/{id}', 'templated' => true }, entry_point)
56
- link._expand(id: '1')._url.must_equal '/orders/1'
56
+ _(link._expand(id: '1')._url).must_equal '/orders/1'
57
57
  end
58
58
 
59
59
  it 'expands an uri template without variables' do
60
60
  link = Link.new('key', { 'href' => '/orders/{id}', 'templated' => true }, entry_point)
61
- link._expand._url.must_equal '/orders/'
62
- link._url.must_equal '/orders/'
61
+ _(link._expand._url).must_equal '/orders/'
62
+ _(link._url).must_equal '/orders/'
63
63
  end
64
64
  end
65
65
 
66
66
  describe 'query string argument' do
67
67
  it 'builds a Link with the templated URI representation' do
68
68
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
69
- link._expand(id: '1')._url.must_equal '/orders?id=1'
69
+ _(link._expand(id: '1')._url).must_equal '/orders?id=1'
70
70
  end
71
71
 
72
72
  it 'expands an uri template without variables' do
73
73
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
74
- link._expand._url.must_equal '/orders'
75
- link._url.must_equal '/orders'
74
+ _(link._expand._url).must_equal '/orders'
75
+ _(link._url).must_equal '/orders'
76
76
  end
77
77
 
78
78
  it 'does not expand unknown variables' do
79
79
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
80
- link._expand(unknown: '1')._url.must_equal '/orders'
80
+ _(link._expand(unknown: '1')._url).must_equal '/orders'
81
81
  end
82
82
 
83
83
  it 'only expands known variables' do
84
84
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
85
- link._expand(unknown: '1', id: '2')._url.must_equal '/orders?id=2'
85
+ _(link._expand(unknown: '1', id: '2')._url).must_equal '/orders?id=2'
86
86
  end
87
87
 
88
88
  it 'only expands templated links' do
89
89
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => false }, entry_point)
90
- link._expand(id: '1')._url.must_equal '/orders{?id}'
90
+ _(link._expand(id: '1')._url).must_equal '/orders{?id}'
91
91
  end
92
92
  end
93
93
  end
@@ -96,36 +96,36 @@ module Hyperclient
96
96
  it 'expands an uri template without variables' do
97
97
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
98
98
 
99
- link._url.must_equal '/orders'
99
+ _(link._url).must_equal '/orders'
100
100
  end
101
101
 
102
102
  it 'expands an uri template with variables' do
103
103
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, id: 1)
104
104
 
105
- link._url.must_equal '/orders?id=1'
105
+ _(link._url).must_equal '/orders?id=1'
106
106
  end
107
107
 
108
108
  it 'does not expand an uri template with unknown variables' do
109
109
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, unknown: 1)
110
110
 
111
- link._url.must_equal '/orders'
111
+ _(link._url).must_equal '/orders'
112
112
  end
113
113
 
114
114
  it 'only expands known variables in a uri template' do
115
115
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, unknown: 1, id: 2)
116
116
 
117
- link._url.must_equal '/orders?id=2'
117
+ _(link._url).must_equal '/orders?id=2'
118
118
  end
119
119
 
120
120
  it 'returns the link when no uri template' do
121
121
  link = Link.new('key', { 'href' => '/orders' }, entry_point)
122
- link._url.must_equal '/orders'
122
+ _(link._url).must_equal '/orders'
123
123
  end
124
124
 
125
125
  it 'aliases to_s to _url' do
126
126
  link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, id: 1)
127
127
 
128
- link.to_s.must_equal '/orders?id=1'
128
+ _(link.to_s).must_equal '/orders?id=1'
129
129
  end
130
130
  end
131
131
 
@@ -151,7 +151,7 @@ module Hyperclient
151
151
  stub.get('http://api.example.org/productions/1') { [200, {}, nil] }
152
152
  end
153
153
 
154
- link._get.must_be_kind_of Resource
154
+ _(link._get).must_be_kind_of Resource
155
155
  end
156
156
 
157
157
  it 'raises exceptions by default' do
@@ -161,7 +161,7 @@ module Hyperclient
161
161
  stub.get('http://api.example.org/productions/1') { [400, {}, nil] }
162
162
  end
163
163
 
164
- -> { link._get }.must_raise Faraday::ClientError
164
+ _(-> { link._get }).must_raise Faraday::ClientError
165
165
  end
166
166
  end
167
167
 
@@ -173,7 +173,7 @@ module Hyperclient
173
173
  stub.options('http://api.example.org/productions/1') { [200, {}, nil] }
174
174
  end
175
175
 
176
- link._options.must_be_kind_of Resource
176
+ _(link._options).must_be_kind_of Resource
177
177
  end
178
178
  end
179
179
 
@@ -185,7 +185,7 @@ module Hyperclient
185
185
  stub.head('http://api.example.org/productions/1') { [200, {}, nil] }
186
186
  end
187
187
 
188
- link._head.must_be_kind_of Resource
188
+ _(link._head).must_be_kind_of Resource
189
189
  end
190
190
  end
191
191
 
@@ -197,7 +197,7 @@ module Hyperclient
197
197
  stub.delete('http://api.example.org/productions/1') { [200, {}, nil] }
198
198
  end
199
199
 
200
- link._delete.must_be_kind_of Resource
200
+ _(link._delete).must_be_kind_of Resource
201
201
  end
202
202
  end
203
203
 
@@ -209,7 +209,7 @@ module Hyperclient
209
209
  stub.post('http://api.example.org/productions/1') { [200, {}, nil] }
210
210
  end
211
211
 
212
- link._post('foo' => 'bar').must_be_kind_of Resource
212
+ _(link._post('foo' => 'bar')).must_be_kind_of Resource
213
213
  end
214
214
 
215
215
  it 'defaults params to an empty hash' do
@@ -217,7 +217,7 @@ module Hyperclient
217
217
  stub.post('http://api.example.org/productions/1') { [200, {}, nil] }
218
218
  end
219
219
 
220
- link._post.must_be_kind_of Resource
220
+ _(link._post).must_be_kind_of Resource
221
221
  end
222
222
  end
223
223
 
@@ -229,7 +229,7 @@ module Hyperclient
229
229
  stub.put('http://api.example.org/productions/1', '{"foo":"bar"}') { [200, {}, nil] }
230
230
  end
231
231
 
232
- link._put('foo' => 'bar').must_be_kind_of Resource
232
+ _(link._put('foo' => 'bar')).must_be_kind_of Resource
233
233
  end
234
234
 
235
235
  it 'defaults params to an empty hash' do
@@ -237,7 +237,7 @@ module Hyperclient
237
237
  stub.put('http://api.example.org/productions/1') { [200, {}, nil] }
238
238
  end
239
239
 
240
- link._put.must_be_kind_of Resource
240
+ _(link._put).must_be_kind_of Resource
241
241
  end
242
242
  end
243
243
 
@@ -249,7 +249,7 @@ module Hyperclient
249
249
  stub.patch('http://api.example.org/productions/1', '{"foo":"bar"}') { [200, {}, nil] }
250
250
  end
251
251
 
252
- link._patch('foo' => 'bar').must_be_kind_of Resource
252
+ _(link._patch('foo' => 'bar')).must_be_kind_of Resource
253
253
  end
254
254
 
255
255
  it 'defaults params to an empty hash' do
@@ -257,7 +257,7 @@ module Hyperclient
257
257
  stub.patch('http://api.example.org/productions/1') { [200, {}, nil] }
258
258
  end
259
259
 
260
- link._patch.must_be_kind_of Resource
260
+ _(link._patch).must_be_kind_of Resource
261
261
  end
262
262
  end
263
263
 
@@ -265,8 +265,8 @@ module Hyperclient
265
265
  it 'outputs a custom-friendly output' do
266
266
  link = Link.new('key', { 'href' => '/productions/1' }, 'foo')
267
267
 
268
- link.inspect.must_include 'Link'
269
- link.inspect.must_include '"href"=>"/productions/1"'
268
+ _(link.inspect).must_include 'Link'
269
+ _(link.inspect).must_include '"href"=>"/productions/1"'
270
270
  end
271
271
  end
272
272
 
@@ -279,8 +279,8 @@ module Hyperclient
279
279
  stub.get('http://api.example.org/orders') { [200, {}, { '_embedded' => { 'orders' => [{ 'id' => 1 }] } }] }
280
280
  end
281
281
 
282
- resource.orders._embedded.orders.first.id.must_equal 1
283
- resource.orders.first.id.must_equal 1
282
+ _(resource.orders._embedded.orders.first.id).must_equal 1
283
+ _(resource.orders.first.id).must_equal 1
284
284
  end
285
285
 
286
286
  it 'can handle false values in the response' do
@@ -290,7 +290,7 @@ module Hyperclient
290
290
  stub.get('http://api.example.org/orders') { [200, {}, { 'any' => false }] }
291
291
  end
292
292
 
293
- resource.orders.any.must_equal false
293
+ _(resource.orders.any).must_equal false
294
294
  end
295
295
 
296
296
  it "doesn't delegate when link key doesn't match" do
@@ -300,8 +300,8 @@ module Hyperclient
300
300
  stub.get('http://api.example.org/orders') { [200, {}, { '_embedded' => { 'orders' => [{ 'id' => 1 }] } }] }
301
301
  end
302
302
 
303
- resource.foos._embedded.orders.first.id.must_equal 1
304
- resource.foos.first.must_be_nil
303
+ _(resource.foos._embedded.orders.first.id).must_equal 1
304
+ _(resource.foos.first).must_be_nil
305
305
  end
306
306
 
307
307
  it 'backtracks when navigating links' do
@@ -311,7 +311,7 @@ module Hyperclient
311
311
  stub.get('http://api.example.org/page2') { [200, {}, { '_links' => { 'next' => { 'href' => 'http://api.example.org/page3' } } }] }
312
312
  end
313
313
 
314
- resource.next._links.next._url.must_equal 'http://api.example.org/page3'
314
+ _(resource.next._links.next._url).must_equal 'http://api.example.org/page3'
315
315
  end
316
316
  end
317
317
 
@@ -335,18 +335,18 @@ module Hyperclient
335
335
  end
336
336
 
337
337
  it 'raises an error when the method does not exist in the resource' do
338
- -> { link.this_method_does_not_exist }.must_raise NoMethodError
338
+ _(-> { link.this_method_does_not_exist }).must_raise NoMethodError
339
339
  end
340
340
 
341
341
  it 'responds to missing methods' do
342
342
  resource.expects(:respond_to?).with('orders').returns(false)
343
343
  resource.expects(:respond_to?).with('embedded').returns(true)
344
- link.respond_to?(:embedded).must_equal true
344
+ _(link.respond_to?(:embedded)).must_equal true
345
345
  end
346
346
 
347
347
  it 'does not delegate to_ary to resource' do
348
348
  resource.expects(:to_ary).never
349
- [[link, link]].flatten.must_equal [link, link]
349
+ _([[link, link]].flatten).must_equal [link, link]
350
350
  end
351
351
  end
352
352
  end