restify 1.15.2 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -2
- data/README.md +23 -31
- data/doc/file.README.html +192 -0
- data/lib/restify/adapter/base.rb +4 -0
- data/lib/restify/adapter/telemetry.rb +54 -0
- data/lib/restify/adapter/typhoeus.rb +37 -4
- data/lib/restify/context.rb +3 -3
- data/lib/restify/error.rb +2 -2
- data/lib/restify/link.rb +4 -4
- data/lib/restify/processors/base/parsing.rb +2 -21
- data/lib/restify/processors/base.rb +1 -1
- data/lib/restify/promise.rb +2 -2
- data/lib/restify/registry.rb +1 -1
- data/lib/restify/relation.rb +45 -17
- data/lib/restify/request.rb +6 -6
- data/lib/restify/timeout.rb +2 -2
- data/lib/restify/version.rb +3 -3
- data/lib/restify.rb +0 -1
- data/spec/restify/cache_spec.rb +16 -12
- data/spec/restify/context_spec.rb +8 -3
- data/spec/restify/error_spec.rb +13 -16
- data/spec/restify/features/head_requests_spec.rb +5 -4
- data/spec/restify/features/opentelemetry_spec.rb +46 -0
- data/spec/restify/features/request_bodies_spec.rb +8 -8
- data/spec/restify/features/request_errors_spec.rb +2 -2
- data/spec/restify/features/request_headers_spec.rb +3 -6
- data/spec/restify/features/response_errors_spec.rb +1 -1
- data/spec/restify/features/webmock_spec.rb +27 -0
- data/spec/restify/global_spec.rb +10 -10
- data/spec/restify/processors/base_spec.rb +6 -7
- data/spec/restify/processors/json_spec.rb +21 -62
- data/spec/restify/processors/msgpack_spec.rb +33 -70
- data/spec/restify/promise_spec.rb +31 -31
- data/spec/restify/registry_spec.rb +5 -7
- data/spec/restify/relation_spec.rb +185 -7
- data/spec/restify/resource_spec.rb +47 -53
- data/spec/restify/timeout_spec.rb +3 -3
- data/spec/restify_spec.rb +12 -73
- data/spec/spec_helper.rb +12 -15
- data/spec/support/opentelemetry.rb +29 -0
- data/spec/support/stub_server.rb +4 -0
- metadata +37 -64
- data/lib/restify/adapter/em.rb +0 -134
- data/lib/restify/adapter/pooled_em.rb +0 -269
@@ -4,31 +4,30 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Restify::Processors::Json do
|
6
6
|
let(:context) { Restify::Context.new('http://test.host/') }
|
7
|
-
let(:response) {
|
7
|
+
let(:response) { instance_double(Restify::Response) }
|
8
8
|
|
9
9
|
before do
|
10
|
-
allow(response).to
|
11
|
-
allow(response).to receive(:follow_location).and_return nil
|
10
|
+
allow(response).to receive_messages(links: [], follow_location: nil)
|
12
11
|
end
|
13
12
|
|
14
13
|
describe 'class' do
|
15
14
|
describe '#accept?' do
|
16
|
-
subject { described_class.accept?
|
15
|
+
subject(:accept) { described_class.accept?(response) }
|
17
16
|
|
18
17
|
it 'accepts JSON mime type (I)' do
|
19
|
-
|
20
|
-
expect(
|
18
|
+
allow(response).to receive(:content_type).and_return('application/json')
|
19
|
+
expect(accept).to be_truthy
|
21
20
|
end
|
22
21
|
|
23
22
|
it 'accepts JSON mime type (II)' do
|
24
|
-
|
25
|
-
expect(
|
23
|
+
allow(response).to receive(:content_type).and_return('application/json; abc')
|
24
|
+
expect(accept).to be_truthy
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
describe '#resource' do
|
31
|
-
subject { described_class.new(context, response).resource }
|
30
|
+
subject(:resource) { described_class.new(context, response).resource }
|
32
31
|
|
33
32
|
before { allow(response).to receive(:body).and_return(body) }
|
34
33
|
|
@@ -41,7 +40,7 @@ describe Restify::Processors::Json do
|
|
41
40
|
end
|
42
41
|
|
43
42
|
it { is_expected.to be_a Restify::Resource }
|
44
|
-
it { expect(
|
43
|
+
it { expect(resource.response).to be response }
|
45
44
|
it { is_expected.to eq 'json' => 'value' }
|
46
45
|
end
|
47
46
|
|
@@ -53,12 +52,12 @@ describe Restify::Processors::Json do
|
|
53
52
|
end
|
54
53
|
|
55
54
|
it do
|
56
|
-
expect(
|
55
|
+
expect(resource).to eq \
|
57
56
|
'json' => 'value', 'search_url' => 'https://google.com{?q}'
|
58
57
|
end
|
59
58
|
|
60
59
|
it { is_expected.to have_relation :search }
|
61
|
-
it { expect(
|
60
|
+
it { expect(resource.relation(:search)).to eq 'https://google.com{?q}' }
|
62
61
|
end
|
63
62
|
|
64
63
|
context 'object with implicit self relation' do
|
@@ -68,7 +67,7 @@ describe Restify::Processors::Json do
|
|
68
67
|
JSON
|
69
68
|
end
|
70
69
|
|
71
|
-
it { expect(
|
70
|
+
it { expect(resource.relation(:self)).to eq '/self' }
|
72
71
|
end
|
73
72
|
|
74
73
|
context 'single array' do
|
@@ -79,7 +78,7 @@ describe Restify::Processors::Json do
|
|
79
78
|
end
|
80
79
|
|
81
80
|
it { is_expected.to be_a Restify::Resource }
|
82
|
-
it { expect(
|
81
|
+
it { expect(resource.response).to be response }
|
83
82
|
it { is_expected.to eq [1, 2, nil, 'STR'] }
|
84
83
|
end
|
85
84
|
|
@@ -102,11 +101,11 @@ describe Restify::Processors::Json do
|
|
102
101
|
end
|
103
102
|
|
104
103
|
it 'parses objects as resources' do
|
105
|
-
expect(
|
104
|
+
expect(resource).to all(be_a(Restify::Resource))
|
106
105
|
end
|
107
106
|
|
108
107
|
it 'parses relations of resources' do
|
109
|
-
expect(
|
108
|
+
expect(resource.map {|r| r.relation :self }).to eq \
|
110
109
|
['/users/john', '/users/jane']
|
111
110
|
end
|
112
111
|
end
|
@@ -120,14 +119,14 @@ describe Restify::Processors::Json do
|
|
120
119
|
end
|
121
120
|
|
122
121
|
it { is_expected.to be_a Restify::Resource }
|
123
|
-
it { expect(
|
122
|
+
it { expect(resource.response).to be response }
|
124
123
|
|
125
124
|
it 'parses objects as resources' do
|
126
|
-
expect(
|
127
|
-
expect(
|
125
|
+
expect(resource['john']).to be_a Restify::Resource
|
126
|
+
expect(resource['jane']).to be_a Restify::Resource
|
128
127
|
|
129
|
-
expect(
|
130
|
-
expect(
|
128
|
+
expect(resource['john']['name']).to eq 'John'
|
129
|
+
expect(resource['jane']['name']).to eq 'Jane'
|
131
130
|
end
|
132
131
|
end
|
133
132
|
|
@@ -139,49 +138,9 @@ describe Restify::Processors::Json do
|
|
139
138
|
end
|
140
139
|
|
141
140
|
it { is_expected.to be_a Restify::Resource }
|
142
|
-
it { expect(
|
141
|
+
it { expect(resource.response).to be response }
|
143
142
|
it { is_expected.to eq 'BLUB' }
|
144
143
|
end
|
145
|
-
|
146
|
-
context 'with indifferent access' do
|
147
|
-
let(:body) do
|
148
|
-
<<-JSON
|
149
|
-
{"name": "John", "age": 24}
|
150
|
-
JSON
|
151
|
-
end
|
152
|
-
|
153
|
-
it '#key?' do
|
154
|
-
expect(subject).to have_key 'name'
|
155
|
-
expect(subject).to have_key 'age'
|
156
|
-
|
157
|
-
expect(subject).to have_key :name
|
158
|
-
expect(subject).to have_key :age
|
159
|
-
end
|
160
|
-
|
161
|
-
it '#[]' do
|
162
|
-
expect(subject['name']).to eq 'John'
|
163
|
-
expect(subject['age']).to eq 24
|
164
|
-
|
165
|
-
expect(subject[:name]).to eq 'John'
|
166
|
-
expect(subject[:age]).to eq 24
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
context 'with method getter access' do
|
171
|
-
let(:body) do
|
172
|
-
<<-JSON
|
173
|
-
{"name": "John", "age": 24}
|
174
|
-
JSON
|
175
|
-
end
|
176
|
-
|
177
|
-
it '#<method getter>' do
|
178
|
-
expect(subject).to respond_to :name
|
179
|
-
expect(subject).to respond_to :age
|
180
|
-
|
181
|
-
expect(subject.name).to eq 'John'
|
182
|
-
expect(subject.age).to eq 24
|
183
|
-
end
|
184
|
-
end
|
185
144
|
end
|
186
145
|
end
|
187
146
|
end
|
@@ -4,95 +4,94 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Restify::Processors::Msgpack do
|
6
6
|
let(:context) { Restify::Context.new('http://test.host/') }
|
7
|
-
let(:response) {
|
7
|
+
let(:response) { instance_double(Restify::Response) }
|
8
8
|
|
9
9
|
before do
|
10
|
-
allow(response).to
|
11
|
-
allow(response).to receive(:follow_location).and_return nil
|
10
|
+
allow(response).to receive_messages(links: [], follow_location: nil)
|
12
11
|
end
|
13
12
|
|
14
13
|
describe 'class' do
|
15
14
|
describe '#accept?' do
|
16
|
-
subject { described_class.accept?
|
15
|
+
subject(:accept) { described_class.accept?(response) }
|
17
16
|
|
18
17
|
it 'accepts msgpack mime type (I)' do
|
19
|
-
|
20
|
-
expect(
|
18
|
+
allow(response).to receive(:content_type).and_return('application/msgpack')
|
19
|
+
expect(accept).to be_truthy
|
21
20
|
end
|
22
21
|
|
23
22
|
it 'accepts msgpack mime type (II)' do
|
24
|
-
|
25
|
-
expect(
|
23
|
+
allow(response).to receive(:content_type).and_return('application/msgpack; abc')
|
24
|
+
expect(accept).to be_truthy
|
26
25
|
end
|
27
26
|
|
28
27
|
it 'accepts x-msgpack mime type (I)' do
|
29
|
-
|
30
|
-
expect(
|
28
|
+
allow(response).to receive(:content_type).and_return('application/x-msgpack')
|
29
|
+
expect(accept).to be_truthy
|
31
30
|
end
|
32
31
|
|
33
32
|
it 'accepts x-msgpack mime type (II)' do
|
34
|
-
|
35
|
-
expect(
|
33
|
+
allow(response).to receive(:content_type).and_return('application/x-msgpack; abc')
|
34
|
+
expect(accept).to be_truthy
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
39
|
describe '#resource' do
|
41
|
-
subject { described_class.new(context, response).resource }
|
40
|
+
subject(:resource) { described_class.new(context, response).resource }
|
42
41
|
|
43
42
|
before { allow(response).to receive(:body).and_return(body) }
|
44
43
|
|
45
44
|
describe 'parsing' do
|
46
45
|
context 'single object' do
|
47
46
|
let(:body) do
|
48
|
-
|
47
|
+
MessagePack.dump('msg' => 'value')
|
49
48
|
end
|
50
49
|
|
51
50
|
it { is_expected.to be_a Restify::Resource }
|
52
|
-
it { expect(
|
51
|
+
it { expect(resource.response).to be response }
|
53
52
|
it { is_expected.to eq 'msg' => 'value' }
|
54
53
|
end
|
55
54
|
|
56
55
|
context 'object with relation fields' do
|
57
56
|
let(:body) do
|
58
|
-
|
57
|
+
MessagePack.dump(
|
59
58
|
'msg' => 'value',
|
60
59
|
'search_url' => 'https://google.com{?q}',
|
61
60
|
)
|
62
61
|
end
|
63
62
|
|
64
63
|
it do
|
65
|
-
expect(
|
64
|
+
expect(resource).to eq \
|
66
65
|
'msg' => 'value', 'search_url' => 'https://google.com{?q}'
|
67
66
|
end
|
68
67
|
|
69
68
|
it { is_expected.to have_relation :search }
|
70
|
-
it { expect(
|
69
|
+
it { expect(resource.relation(:search)).to eq 'https://google.com{?q}' }
|
71
70
|
end
|
72
71
|
|
73
72
|
context 'object with implicit self relation' do
|
74
73
|
let(:body) do
|
75
|
-
|
74
|
+
MessagePack.dump(
|
76
75
|
'url' => '/self',
|
77
76
|
)
|
78
77
|
end
|
79
78
|
|
80
|
-
it { expect(
|
79
|
+
it { expect(resource.relation(:self)).to eq '/self' }
|
81
80
|
end
|
82
81
|
|
83
82
|
context 'single array' do
|
84
83
|
let(:body) do
|
85
|
-
|
84
|
+
MessagePack.dump([1, 2, nil, 'STR'])
|
86
85
|
end
|
87
86
|
|
88
87
|
it { is_expected.to be_a Restify::Resource }
|
89
|
-
it { expect(
|
88
|
+
it { expect(resource.response).to be response }
|
90
89
|
it { is_expected.to eq [1, 2, nil, 'STR'] }
|
91
90
|
end
|
92
91
|
|
93
92
|
context 'array with objects' do
|
94
93
|
let(:body) do
|
95
|
-
|
94
|
+
MessagePack.dump([{'a' => 0}, {'b' => 1}])
|
96
95
|
end
|
97
96
|
|
98
97
|
it { is_expected.to eq [{'a' => 0}, {'b' => 1}] }
|
@@ -100,87 +99,51 @@ describe Restify::Processors::Msgpack do
|
|
100
99
|
|
101
100
|
context 'array with resources' do
|
102
101
|
let(:body) do
|
103
|
-
|
102
|
+
MessagePack.dump([
|
104
103
|
{'name' => 'John', 'self_url' => '/users/john'},
|
105
104
|
{'name' => 'Jane', 'self_url' => '/users/jane'},
|
106
105
|
])
|
107
106
|
end
|
108
107
|
|
109
108
|
it 'parses objects as resources' do
|
110
|
-
expect(
|
109
|
+
expect(resource).to all(be_a(Restify::Resource))
|
111
110
|
end
|
112
111
|
|
113
112
|
it 'parses relations of resources' do
|
114
|
-
expect(
|
113
|
+
expect(resource.map {|r| r.relation :self }).to eq \
|
115
114
|
['/users/john', '/users/jane']
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
119
118
|
context 'nested objects' do
|
120
119
|
let(:body) do
|
121
|
-
|
120
|
+
MessagePack.dump(
|
122
121
|
'john' => {'name' => 'John'},
|
123
122
|
'jane' => {'name' => 'Jane'},
|
124
123
|
)
|
125
124
|
end
|
126
125
|
|
127
126
|
it { is_expected.to be_a Restify::Resource }
|
128
|
-
it { expect(
|
127
|
+
it { expect(resource.response).to be response }
|
129
128
|
|
130
129
|
it 'parses objects as resources' do
|
131
|
-
expect(
|
132
|
-
expect(
|
130
|
+
expect(resource['john']).to be_a Restify::Resource
|
131
|
+
expect(resource['jane']).to be_a Restify::Resource
|
133
132
|
|
134
|
-
expect(
|
135
|
-
expect(
|
133
|
+
expect(resource['john']['name']).to eq 'John'
|
134
|
+
expect(resource['jane']['name']).to eq 'Jane'
|
136
135
|
end
|
137
136
|
end
|
138
137
|
|
139
138
|
context 'single value' do
|
140
139
|
let(:body) do
|
141
|
-
|
140
|
+
MessagePack.dump('BLUB')
|
142
141
|
end
|
143
142
|
|
144
143
|
it { is_expected.to be_a Restify::Resource }
|
145
|
-
it { expect(
|
144
|
+
it { expect(resource.response).to be response }
|
146
145
|
it { is_expected.to eq 'BLUB' }
|
147
146
|
end
|
148
|
-
|
149
|
-
context 'with indifferent access' do
|
150
|
-
let(:body) do
|
151
|
-
::MessagePack.dump('name' => 'John', 'age' => 24)
|
152
|
-
end
|
153
|
-
|
154
|
-
it '#key?' do
|
155
|
-
expect(subject).to have_key 'name'
|
156
|
-
expect(subject).to have_key 'age'
|
157
|
-
|
158
|
-
expect(subject).to have_key :name
|
159
|
-
expect(subject).to have_key :age
|
160
|
-
end
|
161
|
-
|
162
|
-
it '#[]' do
|
163
|
-
expect(subject['name']).to eq 'John'
|
164
|
-
expect(subject['age']).to eq 24
|
165
|
-
|
166
|
-
expect(subject[:name]).to eq 'John'
|
167
|
-
expect(subject[:age]).to eq 24
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context 'with method getter access' do
|
172
|
-
let(:body) do
|
173
|
-
::MessagePack.dump('name' => 'John', 'age' => 24)
|
174
|
-
end
|
175
|
-
|
176
|
-
it '#<method getter>' do
|
177
|
-
expect(subject).to respond_to :name
|
178
|
-
expect(subject).to respond_to :age
|
179
|
-
|
180
|
-
expect(subject.name).to eq 'John'
|
181
|
-
expect(subject.age).to eq 24
|
182
|
-
end
|
183
|
-
end
|
184
147
|
end
|
185
148
|
end
|
186
149
|
end
|
@@ -7,42 +7,42 @@ describe Restify::Promise do
|
|
7
7
|
|
8
8
|
describe 'factory methods' do
|
9
9
|
describe '#fulfilled' do
|
10
|
-
subject { described_class.fulfilled(fulfill_value) }
|
10
|
+
subject(:promise) { described_class.fulfilled(fulfill_value) }
|
11
11
|
|
12
12
|
let(:fulfill_value) { 42 }
|
13
13
|
|
14
14
|
it 'returns a fulfilled promise' do
|
15
|
-
expect(
|
16
|
-
expect(
|
15
|
+
expect(promise.fulfilled?).to be true
|
16
|
+
expect(promise.rejected?).to be false
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'wraps the given value' do
|
20
|
-
expect(
|
20
|
+
expect(promise.value!).to eq 42
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '#rejected' do
|
25
|
-
subject { described_class.rejected(rejection_reason) }
|
25
|
+
subject(:promise) { described_class.rejected(rejection_reason) }
|
26
26
|
|
27
27
|
let(:rejection_reason) { ArgumentError }
|
28
28
|
|
29
29
|
it 'returns a rejected promise' do
|
30
|
-
expect(
|
31
|
-
expect(
|
30
|
+
expect(promise.fulfilled?).to be false
|
31
|
+
expect(promise.rejected?).to be true
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'bubbles up the caught exception on #value!' do
|
35
|
-
expect {
|
35
|
+
expect { promise.value! }.to raise_error(ArgumentError)
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'swallows the exception on #value' do
|
39
|
-
expect(
|
39
|
+
expect(promise.value).to be_nil
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#create' do
|
44
44
|
context 'when fulfilling the promise in the writer block' do
|
45
|
-
subject do
|
45
|
+
subject(:promise) do
|
46
46
|
described_class.create do |writer|
|
47
47
|
# Calculate a value and fulfill the promise with it
|
48
48
|
writer.fulfill 42
|
@@ -50,17 +50,17 @@ describe Restify::Promise do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'returns a fulfilled promise' do
|
53
|
-
expect(
|
54
|
-
expect(
|
53
|
+
expect(promise.fulfilled?).to be true
|
54
|
+
expect(promise.rejected?).to be false
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'wraps the given value' do
|
58
|
-
expect(
|
58
|
+
expect(promise.value!).to eq 42
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
context 'when rejecting the promise in the writer block' do
|
63
|
-
subject do
|
63
|
+
subject(:promise) do
|
64
64
|
described_class.create do |writer|
|
65
65
|
# Calculate a value and fulfill the promise with it
|
66
66
|
writer.reject ArgumentError
|
@@ -68,21 +68,21 @@ describe Restify::Promise do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'returns a rejected promise' do
|
71
|
-
expect(
|
72
|
-
expect(
|
71
|
+
expect(promise.fulfilled?).to be false
|
72
|
+
expect(promise.rejected?).to be true
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'bubbles up the caught exception on #value!' do
|
76
|
-
expect {
|
76
|
+
expect { promise.value! }.to raise_error(ArgumentError)
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'swallows the exception on #value' do
|
80
|
-
expect(
|
80
|
+
expect(promise.value).to be_nil
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
context 'when fulfilling the promise asynchronously' do
|
85
|
-
subject do
|
85
|
+
subject(:promise) do
|
86
86
|
described_class.create do |writer|
|
87
87
|
Thread.new do
|
88
88
|
sleep 0.1
|
@@ -92,20 +92,20 @@ describe Restify::Promise do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'returns a pending promise' do
|
95
|
-
expect(
|
96
|
-
expect(
|
97
|
-
expect(
|
95
|
+
expect(promise.fulfilled?).to be false
|
96
|
+
expect(promise.rejected?).to be false
|
97
|
+
expect(promise.pending?).to be true
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'waits for the fulfillment value' do
|
101
|
-
expect(
|
101
|
+
expect(promise.value!).to eq 42
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
describe 'result' do
|
108
|
-
subject { described_class.new(*dependencies, &task).value! }
|
108
|
+
subject(:result) { described_class.new(*dependencies, &task).value! }
|
109
109
|
|
110
110
|
let(:dependencies) { [] }
|
111
111
|
let(:task) { nil }
|
@@ -119,7 +119,7 @@ describe Restify::Promise do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'is calculated using the task block' do
|
122
|
-
expect(
|
122
|
+
expect(result).to eq 42
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -133,7 +133,7 @@ describe Restify::Promise do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'is an array of the dependencies\' results' do
|
136
|
-
expect(
|
136
|
+
expect(result).to eq [1, 2, 3]
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -147,7 +147,7 @@ describe Restify::Promise do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'is an array of the dependencies\' results' do
|
150
|
-
expect(
|
150
|
+
expect(result).to eq [1, 2, 3]
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -163,7 +163,7 @@ describe Restify::Promise do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it 'can use the dependencies to calculate the value' do
|
166
|
-
expect(
|
166
|
+
expect(result).to eq 17
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -178,19 +178,19 @@ describe Restify::Promise do
|
|
178
178
|
|
179
179
|
describe '#wait' do
|
180
180
|
it 'can time out' do
|
181
|
-
expect { promise.wait(0.1) }.to raise_error
|
181
|
+
expect { promise.wait(0.1) }.to raise_error Timeout::Error
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
185
185
|
describe '#value' do
|
186
186
|
it 'can time out' do
|
187
|
-
expect { promise.value(0.1) }.to raise_error
|
187
|
+
expect { promise.value(0.1) }.to raise_error Timeout::Error
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
191
|
describe '#value!' do
|
192
192
|
it 'can time out' do
|
193
|
-
expect { promise.value!(0.1) }.to raise_error
|
193
|
+
expect { promise.value!(0.1) }.to raise_error Timeout::Error
|
194
194
|
end
|
195
195
|
end
|
196
196
|
end
|
@@ -3,15 +3,13 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Restify::Registry do
|
6
|
-
|
6
|
+
subject(:registry) { described_class.instance }
|
7
7
|
|
8
8
|
describe 'class' do
|
9
9
|
describe '#instance' do
|
10
|
-
subject { described_class.instance }
|
11
|
-
|
12
10
|
it 'returns singleton instance' do
|
13
|
-
expect(
|
14
|
-
expect(
|
11
|
+
expect(registry).to be_a described_class
|
12
|
+
expect(registry).to be described_class.instance
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
@@ -36,14 +34,14 @@ describe Restify::Registry do
|
|
36
34
|
end
|
37
35
|
|
38
36
|
describe '#store / #fetch' do
|
39
|
-
subject { registry.store
|
37
|
+
subject(:store) { registry.store(name, uri, **opts) }
|
40
38
|
|
41
39
|
let(:name) { 'remote' }
|
42
40
|
let(:uri) { 'http://remote/entry/point' }
|
43
41
|
let(:opts) { {accept: 'application/vnd.remote+json'} }
|
44
42
|
|
45
43
|
it 'stores registry item' do
|
46
|
-
|
44
|
+
store
|
47
45
|
|
48
46
|
item = registry.fetch name
|
49
47
|
|