rabbitmq_http_api_client 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1804b5a58f15be23377604aa4ded51161a53f5d5
4
- data.tar.gz: bc32d5b90c2a6706a407a61dcfedb3d3e927cf7c
3
+ metadata.gz: 544cb8a706ba1359e42ab9bff221cad9b67eb97d
4
+ data.tar.gz: 0eb83fe2a328807ddb76a46ea054bbdcee3ff557
5
5
  SHA512:
6
- metadata.gz: 3af37ad9375df0de92c1728e36cc1c57f47eafc06b684175b57612c095aca0121e924a269b2a39aa8a7cdd5361494541ac0d2a8c2b937ed24328818fd532b777
7
- data.tar.gz: 96ef7bd174555bac699ff7e094a0a0a13d55a14af8fb3c72e820823656448eec82e1935ca7164e4ea4d707e4a7c881cebf0be0ae9cae66641b9453af1210f082
6
+ metadata.gz: 8b6aaab7c0f8e9b4d456368d0490054657793da60baae1b6c32bedb794a986f34670c7e15a1a3903c1b7fccd77ee07665cde0f6eadfbe553688842d58f1a062f
7
+ data.tar.gz: 9e73ea391051df2d4e3ab029bb6c788036c6ab1769a67da098ee04ec0269dacd35e57ccb93545e818b3e04fee5770ced227057f76da5e777144821568e972064
data/ChangeLog.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## Changes Between 1.4.0 and 1.5.0
2
+
3
+ ### Support for URIs containing a path
4
+
5
+ If provided endpoint contains a path, it will be used instead of `/api`.
6
+
7
+ Contributed by Pol Miro.
8
+
1
9
  ## Changes Between 1.3.0 and 1.4.0
2
10
 
3
11
  ### Protocol Ports for Non-Administrators
@@ -5,7 +13,7 @@
5
13
  `Client#protocol_ports` no longer fails with a nil pointer exception
6
14
  for non-administrators.
7
15
 
8
- ### Hashi Upgrade
16
+ ### Hashie Upgrade
9
17
 
10
18
  The library now depends on `hashie ~> 3.2`.
11
19
 
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :development, :test do
4
- gem "rspec"
4
+ gem "rspec", ">= 3.2.0"
5
5
  gem "json", :platform => :ruby_18
6
- gem "bunny", ">= 1.6.3"
6
+ gem "bunny", ">= 1.7.0"
7
7
 
8
8
  gem "rantly"
9
9
  end
data/README.md CHANGED
@@ -33,7 +33,7 @@ All versions require [RabbitMQ Management UI plugin](http://www.rabbitmq.com/man
33
33
 
34
34
  Add this line to your application's Gemfile:
35
35
 
36
- gem 'rabbitmq_http_api_client', '>= 1.3.0'
36
+ gem 'rabbitmq_http_api_client', '>= 1.4.0'
37
37
 
38
38
  And then execute:
39
39
 
@@ -29,7 +29,7 @@ module RabbitMQ
29
29
  end
30
30
 
31
31
  def overview
32
- decode_resource(@connection.get("/api/overview"))
32
+ decode_resource(@connection.get("overview"))
33
33
  end
34
34
 
35
35
  # Returns a list of messaging protocols supported by
@@ -61,19 +61,19 @@ module RabbitMQ
61
61
  end
62
62
 
63
63
  def list_nodes
64
- decode_resource_collection(@connection.get("/api/nodes"))
64
+ decode_resource_collection(@connection.get("nodes"))
65
65
  end
66
66
 
67
67
  def node_info(name)
68
- decode_resource(@connection.get("/api/nodes/#{uri_encode(name)}"))
68
+ decode_resource(@connection.get("nodes/#{uri_encode(name)}"))
69
69
  end
70
70
 
71
71
  def list_extensions
72
- decode_resource_collection(@connection.get("/api/extensions"))
72
+ decode_resource_collection(@connection.get("extensions"))
73
73
  end
74
74
 
75
75
  def list_definitions
76
- decode_resource(@connection.get("/api/definitions"))
76
+ decode_resource(@connection.get("definitions"))
77
77
  end
78
78
 
79
79
  def upload_definitions(defs)
@@ -81,30 +81,30 @@ module RabbitMQ
81
81
  end
82
82
 
83
83
  def list_connections
84
- decode_resource_collection(@connection.get("/api/connections"))
84
+ decode_resource_collection(@connection.get("connections"))
85
85
  end
86
86
 
87
87
  def connection_info(name)
88
- decode_resource(@connection.get("/api/connections/#{uri_encode(name)}"))
88
+ decode_resource(@connection.get("connections/#{uri_encode(name)}"))
89
89
  end
90
90
 
91
91
  def close_connection(name)
92
- decode_resource(@connection.delete("/api/connections/#{uri_encode(name)}"))
92
+ decode_resource(@connection.delete("connections/#{uri_encode(name)}"))
93
93
  end
94
94
 
95
95
  def list_channels
96
- decode_resource_collection(@connection.get("/api/channels"))
96
+ decode_resource_collection(@connection.get("channels"))
97
97
  end
98
98
 
99
99
  def channel_info(name)
100
- decode_resource(@connection.get("/api/channels/#{uri_encode(name)}"))
100
+ decode_resource(@connection.get("channels/#{uri_encode(name)}"))
101
101
  end
102
102
 
103
103
  def list_exchanges(vhost = nil)
104
104
  path = if vhost.nil?
105
- "/api/exchanges"
105
+ "exchanges"
106
106
  else
107
- "/api/exchanges/#{uri_encode(vhost)}"
107
+ "exchanges/#{uri_encode(vhost)}"
108
108
  end
109
109
 
110
110
  decode_resource_collection(@connection.get(path))
@@ -118,7 +118,7 @@ module RabbitMQ
118
118
  :arguments => {}
119
119
  }.merge(attributes)
120
120
 
121
- response = @connection.put("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req|
121
+ response = @connection.put("exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req|
122
122
  req.headers['Content-Type'] = 'application/json'
123
123
  req.body = MultiJson.dump(opts)
124
124
  end
@@ -126,37 +126,37 @@ module RabbitMQ
126
126
  end
127
127
 
128
128
  def delete_exchange(vhost, name)
129
- decode_resource(@connection.delete("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}"))
129
+ decode_resource(@connection.delete("exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}"))
130
130
  end
131
131
 
132
132
  def exchange_info(vhost, name)
133
- decode_resource(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}"))
133
+ decode_resource(@connection.get("exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}"))
134
134
  end
135
135
 
136
136
  def list_bindings_by_source(vhost, exchange)
137
- decode_resource_collection(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/source"))
137
+ decode_resource_collection(@connection.get("exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/source"))
138
138
  end
139
139
 
140
140
  def list_bindings_by_destination(vhost, exchange)
141
- decode_resource_collection(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/destination"))
141
+ decode_resource_collection(@connection.get("exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/destination"))
142
142
  end
143
143
 
144
144
  def list_queues(vhost = nil)
145
145
  path = if vhost.nil?
146
- "/api/queues"
146
+ "queues"
147
147
  else
148
- "/api/queues/#{uri_encode(vhost)}"
148
+ "queues/#{uri_encode(vhost)}"
149
149
  end
150
150
 
151
151
  decode_resource_collection(@connection.get(path))
152
152
  end
153
153
 
154
154
  def queue_info(vhost, name)
155
- decode_resource(@connection.get("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}"))
155
+ decode_resource(@connection.get("queues/#{uri_encode(vhost)}/#{uri_encode(name)}"))
156
156
  end
157
157
 
158
158
  def declare_queue(vhost, name, attributes)
159
- response = @connection.put("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req|
159
+ response = @connection.put("queues/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req|
160
160
  req.headers['Content-Type'] = "application/json"
161
161
  req.body = MultiJson.dump(attributes)
162
162
  end
@@ -164,20 +164,20 @@ module RabbitMQ
164
164
  end
165
165
 
166
166
  def delete_queue(vhost, name)
167
- decode_resource(@connection.delete("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}"))
167
+ decode_resource(@connection.delete("queues/#{uri_encode(vhost)}/#{uri_encode(name)}"))
168
168
  end
169
169
 
170
170
  def list_queue_bindings(vhost, queue)
171
- decode_resource_collection(@connection.get("/api/queues/#{uri_encode(vhost)}/#{uri_encode(queue)}/bindings"))
171
+ decode_resource_collection(@connection.get("queues/#{uri_encode(vhost)}/#{uri_encode(queue)}/bindings"))
172
172
  end
173
173
 
174
174
  def purge_queue(vhost, name)
175
- @connection.delete("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}/contents")
175
+ @connection.delete("queues/#{uri_encode(vhost)}/#{uri_encode(name)}/contents")
176
176
  Hashie::Mash.new
177
177
  end
178
178
 
179
179
  def get_messages(vhost, name, options)
180
- response = @connection.post("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}/get") do |req|
180
+ response = @connection.post("queues/#{uri_encode(vhost)}/#{uri_encode(name)}/get") do |req|
181
181
  req.headers['Content-Type'] = "application/json"
182
182
  req.body = MultiJson.dump(options)
183
183
  end
@@ -186,24 +186,24 @@ module RabbitMQ
186
186
 
187
187
  def list_bindings(vhost = nil)
188
188
  path = if vhost.nil?
189
- "/api/bindings"
189
+ "bindings"
190
190
  else
191
- "/api/bindings/#{uri_encode(vhost)}"
191
+ "bindings/#{uri_encode(vhost)}"
192
192
  end
193
193
 
194
194
  decode_resource_collection(@connection.get(path))
195
195
  end
196
196
 
197
197
  def list_bindings_between_queue_and_exchange(vhost, queue, exchange)
198
- decode_resource_collection(@connection.get("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}"))
198
+ decode_resource_collection(@connection.get("bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}"))
199
199
  end
200
200
 
201
201
  def queue_binding_info(vhost, queue, exchange, properties_key)
202
- decode_resource(@connection.get("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}/#{uri_encode(properties_key)}"))
202
+ decode_resource(@connection.get("bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}/#{uri_encode(properties_key)}"))
203
203
  end
204
204
 
205
205
  def bind_queue(vhost, queue, exchange, routing_key, arguments = [])
206
- resp = @connection.post("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}") do |req|
206
+ resp = @connection.post("bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}") do |req|
207
207
  req.headers['Content-Type'] = 'application/json'
208
208
  req.body = MultiJson.dump({:routing_key => routing_key, :arguments => arguments})
209
209
  end
@@ -211,49 +211,49 @@ module RabbitMQ
211
211
  end
212
212
 
213
213
  def delete_queue_binding(vhost, queue, exchange, properties_key)
214
- resp = @connection.delete("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}/#{uri_encode(properties_key)}")
214
+ resp = @connection.delete("bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}/#{uri_encode(properties_key)}")
215
215
  resp.success?
216
216
  end
217
217
 
218
218
 
219
219
 
220
220
  def list_vhosts
221
- decode_resource_collection(@connection.get("/api/vhosts"))
221
+ decode_resource_collection(@connection.get("vhosts"))
222
222
  end
223
223
 
224
224
  def vhost_info(name)
225
- decode_resource(@connection.get("/api/vhosts/#{uri_encode(name)}"))
225
+ decode_resource(@connection.get("vhosts/#{uri_encode(name)}"))
226
226
  end
227
227
 
228
228
  def create_vhost(name)
229
- response = @connection.put("/api/vhosts/#{uri_encode(name)}") do |req|
229
+ response = @connection.put("vhosts/#{uri_encode(name)}") do |req|
230
230
  req.headers['Content-Type'] = "application/json"
231
231
  end
232
232
  decode_resource(response)
233
233
  end
234
234
 
235
235
  def delete_vhost(name)
236
- decode_resource(@connection.delete("/api/vhosts/#{uri_encode(name)}"))
236
+ decode_resource(@connection.delete("vhosts/#{uri_encode(name)}"))
237
237
  end
238
238
 
239
239
 
240
240
 
241
241
  def list_permissions(vhost = nil)
242
242
  path = if vhost
243
- "/api/vhosts/#{uri_encode(vhost)}/permissions"
243
+ "vhosts/#{uri_encode(vhost)}/permissions"
244
244
  else
245
- "/api/permissions"
245
+ "permissions"
246
246
  end
247
247
 
248
248
  decode_resource_collection(@connection.get(path))
249
249
  end
250
250
 
251
251
  def list_permissions_of(vhost, user)
252
- decode_resource(@connection.get("/api/permissions/#{uri_encode(vhost)}/#{uri_encode(user)}"))
252
+ decode_resource(@connection.get("permissions/#{uri_encode(vhost)}/#{uri_encode(user)}"))
253
253
  end
254
254
 
255
255
  def update_permissions_of(vhost, user, attributes)
256
- response = @connection.put("/api/permissions/#{uri_encode(vhost)}/#{uri_encode(user)}") do |req|
256
+ response = @connection.put("permissions/#{uri_encode(vhost)}/#{uri_encode(user)}") do |req|
257
257
  req.headers['Content-Type'] = "application/json"
258
258
  req.body = MultiJson.dump(attributes)
259
259
  end
@@ -261,21 +261,21 @@ module RabbitMQ
261
261
  end
262
262
 
263
263
  def clear_permissions_of(vhost, user)
264
- decode_resource(@connection.delete("/api/permissions/#{uri_encode(vhost)}/#{uri_encode(user)}"))
264
+ decode_resource(@connection.delete("permissions/#{uri_encode(vhost)}/#{uri_encode(user)}"))
265
265
  end
266
266
 
267
267
 
268
268
 
269
269
  def list_users
270
- decode_resource_collection(@connection.get("/api/users"))
270
+ decode_resource_collection(@connection.get("users"))
271
271
  end
272
272
 
273
273
  def user_info(name)
274
- decode_resource(@connection.get("/api/users/#{uri_encode(name)}"))
274
+ decode_resource(@connection.get("users/#{uri_encode(name)}"))
275
275
  end
276
276
 
277
277
  def update_user(name, attributes)
278
- response = @connection.put("/api/users/#{uri_encode(name)}") do |req|
278
+ response = @connection.put("users/#{uri_encode(name)}") do |req|
279
279
  req.headers['Content-Type'] = "application/json"
280
280
  req.body = MultiJson.dump(attributes)
281
281
  end
@@ -284,24 +284,24 @@ module RabbitMQ
284
284
  alias create_user update_user
285
285
 
286
286
  def delete_user(name)
287
- decode_resource(@connection.delete("/api/users/#{uri_encode(name)}"))
287
+ decode_resource(@connection.delete("users/#{uri_encode(name)}"))
288
288
  end
289
289
 
290
290
  def user_permissions(name)
291
- decode_resource_collection(@connection.get("/api/users/#{uri_encode(name)}/permissions"))
291
+ decode_resource_collection(@connection.get("users/#{uri_encode(name)}/permissions"))
292
292
  end
293
293
 
294
294
  def whoami
295
- decode_resource(@connection.get("/api/whoami"))
295
+ decode_resource(@connection.get("whoami"))
296
296
  end
297
297
 
298
298
 
299
299
 
300
300
  def list_policies(vhost = nil)
301
301
  path = if vhost
302
- "/api/policies/#{uri_encode(vhost)}"
302
+ "policies/#{uri_encode(vhost)}"
303
303
  else
304
- "/api/policies"
304
+ "policies"
305
305
  end
306
306
 
307
307
  decode_resource_collection(@connection.get(path))
@@ -309,15 +309,15 @@ module RabbitMQ
309
309
 
310
310
  def list_policies_of(vhost, name = nil)
311
311
  path = if name
312
- "/api/policies/#{uri_encode(vhost)}/#{uri_encode(name)}"
312
+ "policies/#{uri_encode(vhost)}/#{uri_encode(name)}"
313
313
  else
314
- "/api/policies/#{uri_encode(vhost)}"
314
+ "policies/#{uri_encode(vhost)}"
315
315
  end
316
316
  decode_resource_collection(@connection.get(path))
317
317
  end
318
318
 
319
319
  def update_policies_of(vhost, name, attributes)
320
- response = @connection.put("/api/policies/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req|
320
+ response = @connection.put("policies/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req|
321
321
  req.headers['Content-Type'] = "application/json"
322
322
  req.body = MultiJson.dump(attributes)
323
323
  end
@@ -325,7 +325,7 @@ module RabbitMQ
325
325
  end
326
326
 
327
327
  def clear_policies_of(vhost, name)
328
- decode_resource(@connection.delete("/api/policies/#{uri_encode(vhost)}/#{uri_encode(name)}"))
328
+ decode_resource(@connection.delete("policies/#{uri_encode(vhost)}/#{uri_encode(name)}"))
329
329
  end
330
330
 
331
331
 
@@ -333,24 +333,24 @@ module RabbitMQ
333
333
 
334
334
  def list_parameters(component = nil)
335
335
  path = if component
336
- "/api/parameters/#{uri_encode(component)}"
336
+ "parameters/#{uri_encode(component)}"
337
337
  else
338
- "/api/parameters"
338
+ "parameters"
339
339
  end
340
340
  decode_resource_collection(@connection.get(path))
341
341
  end
342
342
 
343
343
  def list_parameters_of(component, vhost, name = nil)
344
344
  path = if name
345
- "/api/parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(name)}"
345
+ "parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(name)}"
346
346
  else
347
- "/api/parameters/#{uri_encode(component)}/#{uri_encode(vhost)}"
347
+ "parameters/#{uri_encode(component)}/#{uri_encode(vhost)}"
348
348
  end
349
349
  decode_resource_collection(@connection.get(path))
350
350
  end
351
351
 
352
352
  def update_parameters_of(component, vhost, name, attributes)
353
- response = @connection.put("/api/parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req|
353
+ response = @connection.put("parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(name)}") do |req|
354
354
  req.headers['Content-Type'] = "application/json"
355
355
  req.body = MultiJson.dump(attributes)
356
356
  end
@@ -358,13 +358,13 @@ module RabbitMQ
358
358
  end
359
359
 
360
360
  def clear_parameters_of(component, vhost, name)
361
- decode_resource(@connection.delete("/api/parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(name)}"))
361
+ decode_resource(@connection.delete("parameters/#{uri_encode(component)}/#{uri_encode(vhost)}/#{uri_encode(name)}"))
362
362
  end
363
363
 
364
364
 
365
365
 
366
366
  def aliveness_test(vhost)
367
- r = @connection.get("/api/aliveness-test/#{uri_encode(vhost)}")
367
+ r = @connection.get("aliveness-test/#{uri_encode(vhost)}")
368
368
  r.body["status"] == "ok"
369
369
  end
370
370
 
@@ -373,11 +373,12 @@ module RabbitMQ
373
373
 
374
374
  def initialize_connection(endpoint, options = {})
375
375
  uri = URI.parse(endpoint)
376
-
376
+ uri.path = "/api" if ["","/"].include?(uri.path)
377
377
  user = uri.user || options.delete(:username) || "guest"
378
378
  password = uri.password || options.delete(:password) || "guest"
379
+ options = options.merge(:url => uri.to_s)
379
380
 
380
- @connection = Faraday.new(endpoint, options) do |conn|
381
+ @connection = Faraday.new(options) do |conn|
381
382
  conn.basic_auth user, password
382
383
  conn.use FaradayMiddleware::FollowRedirects, :limit => 3
383
384
  conn.use Faraday::Response::RaiseError
@@ -1,7 +1,7 @@
1
1
  module RabbitMQ
2
2
  module HTTP
3
3
  class Client
4
- VERSION = "1.4.0"
4
+ VERSION = "1.5.0"
5
5
  end
6
6
  end
7
7
  end
@@ -17,6 +17,19 @@ describe RabbitMQ::HTTP::Client do
17
17
  @connection.close
18
18
  end
19
19
 
20
+ #
21
+ # Default endpoint path
22
+ #
23
+ describe "default endpoint path" do
24
+ it "does NOT append '/api' if the endpoint provides a path" do
25
+ c = described_class.connect("http://guest:guest@127.0.0.1:15672/api")
26
+
27
+ r = c.overview
28
+ expect(r.rabbitmq_version).to_not be_nil
29
+ expect(r.erlang_version).to_not be_nil
30
+ end
31
+ end
32
+
20
33
 
21
34
  #
22
35
  # URI-only access
@@ -27,8 +40,8 @@ describe RabbitMQ::HTTP::Client do
27
40
  c = described_class.connect("http://guest:guest@127.0.0.1:15672")
28
41
 
29
42
  r = c.overview
30
- r.rabbitmq_version.should_not be_nil
31
- r.erlang_version.should_not be_nil
43
+ expect(r.rabbitmq_version).to_not be_nil
44
+ expect(r.erlang_version).to_not be_nil
32
45
  end
33
46
  end
34
47
 
@@ -44,11 +57,11 @@ describe RabbitMQ::HTTP::Client do
44
57
  ts = r.exchange_types.map { |h| h.name }.
45
58
  sort
46
59
  ["direct", "fanout", "headers", "topic"].each do |t|
47
- ts.should include(t)
60
+ expect(ts).to include(t)
48
61
  end
49
62
 
50
- r.rabbitmq_version.should_not be_nil
51
- r.erlang_version.should_not be_nil
63
+ expect(r.rabbitmq_version).to_not be_nil
64
+ expect(r.erlang_version).to_not be_nil
52
65
  end
53
66
  end
54
67
 
@@ -56,7 +69,7 @@ describe RabbitMQ::HTTP::Client do
56
69
  it "returns a list of enabled protocols" do
57
70
  xs = subject.enabled_protocols
58
71
 
59
- xs.should include("amqp")
72
+ expect(xs).to include("amqp")
60
73
  end
61
74
  end
62
75
 
@@ -65,7 +78,7 @@ describe RabbitMQ::HTTP::Client do
65
78
  xs = subject.protocol_ports
66
79
 
67
80
  # hash of protocol => port
68
- xs["amqp"].should == 5672
81
+ expect(xs["amqp"]).to eq(5672)
69
82
  end
70
83
  end
71
84
 
@@ -79,21 +92,9 @@ describe RabbitMQ::HTTP::Client do
79
92
  n = nodes.first
80
93
 
81
94
  rabbit = n.applications.detect { |app| app.name == "rabbit" }
82
- rabbit.description.should == "RabbitMQ"
95
+ expect(rabbit.description).to eq("RabbitMQ")
83
96
 
84
- n.name.should =~ /^rabbit/
85
- n.partitions.should == []
86
- n.fd_used.should_not be_nil
87
- n.fd_total.should_not be_nil
88
- n.sockets_used.should_not be_nil
89
- n.sockets_total.should_not be_nil
90
- n.mem_used.should_not be_nil
91
- n.mem_limit.should_not be_nil
92
- n.disk_free_limit.should_not be_nil
93
- n.disk_free.should_not be_nil
94
- n.proc_used.should_not be_nil
95
- n.proc_total.should_not be_nil
96
- n.run_queue.should_not be_nil
97
+ expect(n.name).to match(/^rabbit/)
97
98
  end
98
99
  end
99
100
 
@@ -103,22 +104,9 @@ describe RabbitMQ::HTTP::Client do
103
104
  n = subject.node_info(ns.first.name)
104
105
 
105
106
  rabbit = n.applications.detect { |app| app.name == "rabbit" }
106
- rabbit.description.should == "RabbitMQ"
107
+ expect(rabbit.description).to eq("RabbitMQ")
107
108
 
108
- n.name.should =~ /^rabbit/
109
- n.partitions.should == []
110
- n.fd_used.should_not be_nil
111
- n.fd_total.should_not be_nil
112
- n.sockets_used.should_not be_nil
113
- n.sockets_total.should_not be_nil
114
- n.mem_used.should_not be_nil
115
- n.mem_limit.should_not be_nil
116
- n.disk_free_limit.should_not be_nil
117
- n.disk_free.should_not be_nil
118
- n.proc_used.should_not be_nil
119
- n.proc_total.should_not be_nil
120
- n.run_queue.should_not be_nil
121
- n.running.should be_true
109
+ expect(n.name).to match(/^rabbit/)
122
110
  end
123
111
  end
124
112
 
@@ -129,9 +117,8 @@ describe RabbitMQ::HTTP::Client do
129
117
  describe "GET /api/extensions" do
130
118
  it "returns a list of enabled management plugin extensions" do
131
119
  xs = subject.list_extensions
132
- f = xs.first
133
120
 
134
- ["dispatcher.js", "shovel.js"].should include(f.javascript)
121
+ expect(xs).to be_kind_of(Array)
135
122
  end
136
123
  end
137
124
 
@@ -143,11 +130,11 @@ describe RabbitMQ::HTTP::Client do
143
130
  it "returns a list of all resources/definitions (vhosts, users, permissions, queues, exchanges, bindings, etc)" do
144
131
  xs = subject.list_definitions
145
132
 
146
- xs.bindings.should be_instance_of(Array)
147
- xs.queues.should be_instance_of(Array)
148
- xs.exchanges.should be_instance_of(Array)
149
- xs.users.should be_instance_of(Array)
150
- xs.vhosts.should be_instance_of(Array)
133
+ expect(xs.bindings).to be_instance_of(Array)
134
+ expect(xs.queues).to be_instance_of(Array)
135
+ expect(xs.exchanges).to be_instance_of(Array)
136
+ expect(xs.users).to be_instance_of(Array)
137
+ expect(xs.vhosts).to be_instance_of(Array)
151
138
  end
152
139
  end
153
140
 
@@ -169,8 +156,8 @@ describe RabbitMQ::HTTP::Client do
169
156
  xs = subject.list_connections
170
157
  f = xs.first
171
158
 
172
- f.name.should =~ /127.0.0.1/
173
- f.client_properties.product.should == "Bunny"
159
+ expect(f.name).to match(/127.0.0.1/)
160
+ expect(f.client_properties.product).to eq("Bunny")
174
161
  end
175
162
  end
176
163
 
@@ -179,21 +166,23 @@ describe RabbitMQ::HTTP::Client do
179
166
  xs = subject.list_connections
180
167
  c = subject.connection_info(xs.first.name)
181
168
 
182
- c.name.should =~ /127.0.0.1/
183
- c.client_properties.product.should == "Bunny"
169
+ expect(c.name).to match(/127.0.0.1/)
170
+ expect(c.client_properties.product).to eq("Bunny")
184
171
  end
185
172
  end
186
173
 
187
- describe "DELETE /api/connections/:name" do
188
- it "closes the connection" do
189
- pending "Needs investigation, DELETE does not seem to close the connection"
190
- xs = subject.list_connections
191
- c = subject.close_connection(xs.first.name)
174
+ unless ENV["CI"]
175
+ describe "DELETE /api/connections/:name" do
176
+ it "closes the connection" do
177
+ pending "Needs investigation, DELETE does not seem to close the connection"
178
+ xs = subject.list_connections
179
+ c = subject.close_connection(xs.first.name)
192
180
 
193
- c.name.should =~ /127.0.0.1/
194
- c.client_properties.product.should == "Bunny"
181
+ expect(c.name).to match(/127.0.0.1/)
182
+ expect(c.client_properties.product).to eq("Bunny")
195
183
 
196
- @connection.should_not be_open
184
+ expect(@connection).to_not be_open
185
+ end
197
186
  end
198
187
  end
199
188
 
@@ -211,8 +200,8 @@ describe RabbitMQ::HTTP::Client do
211
200
  xs = subject.list_channels
212
201
  f = xs.first
213
202
 
214
- f.number.should be >= 1
215
- f.prefetch_count.should be >= 0
203
+ expect(f.number).to be >= 1
204
+ expect(f.prefetch_count).to be >= 0
216
205
  end
217
206
  end
218
207
 
@@ -225,8 +214,8 @@ describe RabbitMQ::HTTP::Client do
225
214
  xs = subject.list_channels
226
215
  c = subject.channel_info(xs.first.name)
227
216
 
228
- c.number.should be >= 1
229
- c.prefetch_count.should be >= 0
217
+ expect(c.number).to be >= 1
218
+ expect(c.prefetch_count).to be >= 0
230
219
  end
231
220
  end
232
221
 
@@ -239,11 +228,11 @@ describe RabbitMQ::HTTP::Client do
239
228
  xs = subject.list_exchanges
240
229
  f = xs.first
241
230
 
242
- f.type.should_not be_nil
243
- f.name.should_not be_nil
244
- f.vhost.should_not be_nil
245
- f.durable.should_not be_nil
246
- f.auto_delete.should_not be_nil
231
+ expect(f.type).to_not be_nil
232
+ expect(f.name).to_not be_nil
233
+ expect(f.vhost).to_not be_nil
234
+ expect(f.durable).to_not be_nil
235
+ expect(f.auto_delete).to_not be_nil
247
236
  end
248
237
  end
249
238
 
@@ -252,7 +241,7 @@ describe RabbitMQ::HTTP::Client do
252
241
  xs = subject.list_exchanges("/")
253
242
  f = xs.first
254
243
 
255
- f.vhost.should == "/"
244
+ expect(f.vhost).to eq("/")
256
245
  end
257
246
  end
258
247
 
@@ -260,12 +249,10 @@ describe RabbitMQ::HTTP::Client do
260
249
  it "returns information about the exchange" do
261
250
  e = subject.exchange_info("/", "amq.fanout")
262
251
 
263
- e.type.should == "fanout"
264
- e.name.should == "amq.fanout"
265
- e.durable.should be_true
266
- e.vhost.should == "/"
267
- e.internal.should be_false
268
- e.auto_delete.should be_false
252
+ expect(e.type).to eq("fanout")
253
+ expect(e.name).to eq("amq.fanout")
254
+ expect(e.durable).to eq(true)
255
+ expect(e.vhost).to eq("/")
269
256
  end
270
257
  end
271
258
 
@@ -323,11 +310,11 @@ describe RabbitMQ::HTTP::Client do
323
310
  xs = subject.list_bindings_by_source("/", "http.api.tests.fanout")
324
311
  f = xs.first
325
312
 
326
- f.destination.should == q.name
327
- f.destination_type.should == "queue"
328
- f.routing_key.should == ""
329
- f.source.should == e.name
330
- f.vhost.should == "/"
313
+ expect(f.destination).to eq(q.name)
314
+ expect(f.destination_type).to eq("queue")
315
+ expect(f.routing_key).to eq("")
316
+ expect(f.source).to eq(e.name)
317
+ expect(f.vhost).to eq("/")
331
318
 
332
319
  e.delete
333
320
  q.delete
@@ -348,11 +335,11 @@ describe RabbitMQ::HTTP::Client do
348
335
  xs = subject.list_bindings_by_destination("/", "http.api.tests.fanout1")
349
336
  f = xs.first
350
337
 
351
- f.destination.should == e1.name
352
- f.destination_type.should == "exchange"
353
- f.routing_key.should == ""
354
- f.source.should == e2.name
355
- f.vhost.should == "/"
338
+ expect(f.destination).to eq(e1.name)
339
+ expect(f.destination_type).to eq("exchange")
340
+ expect(f.routing_key).to eq("")
341
+ expect(f.source).to eq(e2.name)
342
+ expect(f.vhost).to eq("/")
356
343
 
357
344
  e1.delete
358
345
  e2.delete
@@ -379,7 +366,7 @@ describe RabbitMQ::HTTP::Client do
379
366
  q = @channel.queue("", :exclusive => true)
380
367
 
381
368
  xs = subject.list_queues
382
- xs.detect { |x| x.name == q.name }.should_not be_empty
369
+ expect(xs.detect { |x| x.name == q.name }).to_not be_empty
383
370
  end
384
371
  end
385
372
 
@@ -392,7 +379,7 @@ describe RabbitMQ::HTTP::Client do
392
379
  q = @channel.queue("", :exclusive => true)
393
380
 
394
381
  xs = subject.list_queues("/")
395
- xs.detect { |x| x.name == q.name }.should_not be_empty
382
+ expect(xs.detect { |x| x.name == q.name }).to_not be_empty
396
383
  end
397
384
  end
398
385
 
@@ -406,21 +393,21 @@ describe RabbitMQ::HTTP::Client do
406
393
  q = @channel.queue("", :exclusive => true, :durable => false)
407
394
  i = subject.queue_info("/", q.name)
408
395
 
409
- i.durable.should be_false
410
- i.durable.should == q.durable?
396
+ expect(i.durable).to eq(false)
397
+ expect(i.durable).to eq(q.durable?)
411
398
 
412
- i.name.should == q.name
413
- i.auto_delete.should == q.auto_delete?
414
- i.active_consumers.should be_nil
415
- i.backing_queue_status.avg_ack_egress_rate.should == 0.0
399
+ expect(i.name).to eq(q.name)
400
+ expect(i.auto_delete).to eq(q.auto_delete?)
401
+ expect(i.active_consumers).to be_nil
402
+ expect(i.backing_queue_status.avg_ack_egress_rate).to eq(0.0)
416
403
  end
417
404
  end
418
405
 
419
406
  context "when queue DOES NOT exist" do
420
407
  it "raises NotFound" do
421
- lambda do
408
+ expect do
422
409
  subject.queue_info("/", Time.now.to_i.to_s)
423
- end.should raise_error(Faraday::Error::ResourceNotFound)
410
+ end.to raise_error(Faraday::Error::ResourceNotFound)
424
411
  end
425
412
  end
426
413
  end
@@ -465,8 +452,8 @@ describe RabbitMQ::HTTP::Client do
465
452
  xs = subject.list_queue_bindings("/", q.name)
466
453
  x = xs.first
467
454
 
468
- x.destination.should == q.name
469
- x.destination_type.should == "queue"
455
+ expect(x.destination).to eq(q.name)
456
+ expect(x.destination_type).to eq("queue")
470
457
  end
471
458
  end
472
459
 
@@ -485,10 +472,10 @@ describe RabbitMQ::HTTP::Client do
485
472
  end
486
473
  sleep 0.7
487
474
 
488
- q.message_count.should == 10
475
+ expect(q.message_count).to eq(10)
489
476
  subject.purge_queue("/", q.name)
490
477
  sleep 0.5
491
- q.message_count.should == 0
478
+ expect(q.message_count).to eq(0)
492
479
  q.delete
493
480
  end
494
481
  end
@@ -509,13 +496,13 @@ describe RabbitMQ::HTTP::Client do
509
496
  end
510
497
  sleep 0.7
511
498
 
512
- q.message_count.should == 10
499
+ expect(q.message_count).to eq(10)
513
500
  xs = subject.get_messages("/", q.name, :count => 10, :requeue => false, :encoding => "auto")
514
501
  m = xs.first
515
502
 
516
- m.properties.content_type.should == "application/xyz"
517
- m.payload.should == "msg 0"
518
- m.payload_encoding.should == "string"
503
+ expect(m.properties.content_type).to eq("application/xyz")
504
+ expect(m.payload).to eq("msg 0")
505
+ expect(m.payload_encoding).to eq("string")
519
506
 
520
507
  q.delete
521
508
  end
@@ -526,11 +513,11 @@ describe RabbitMQ::HTTP::Client do
526
513
  xs = subject.list_bindings
527
514
  b = xs.first
528
515
 
529
- b.destination.should_not be_nil
530
- b.destination_type.should_not be_nil
531
- b.source.should_not be_nil
532
- b.routing_key.should_not be_nil
533
- b.vhost.should_not be_nil
516
+ expect(b.destination).to_not be_nil
517
+ expect(b.destination_type).to_not be_nil
518
+ expect(b.source).to_not be_nil
519
+ expect(b.routing_key).to_not be_nil
520
+ expect(b.vhost).to_not be_nil
534
521
  end
535
522
  end
536
523
 
@@ -539,11 +526,11 @@ describe RabbitMQ::HTTP::Client do
539
526
  xs = subject.list_bindings("/")
540
527
  b = xs.first
541
528
 
542
- b.destination.should_not be_nil
543
- b.destination_type.should_not be_nil
544
- b.source.should_not be_nil
545
- b.routing_key.should_not be_nil
546
- b.vhost.should_not be_nil
529
+ expect(b.destination).to_not be_nil
530
+ expect(b.destination_type).to_not be_nil
531
+ expect(b.source).to_not be_nil
532
+ expect(b.routing_key).to_not be_nil
533
+ expect(b.vhost).to_not be_nil
547
534
  end
548
535
  end
549
536
 
@@ -559,12 +546,12 @@ describe RabbitMQ::HTTP::Client do
559
546
 
560
547
  xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
561
548
  b = xs.first
562
- b.destination.should == q.name
563
- b.destination_type.should == "queue"
564
- b.source.should == x.name
565
- b.routing_key.should_not be_nil
566
- b.properties_key.should_not be_nil
567
- b.vhost.should == "/"
549
+ expect(b.destination).to eq(q.name)
550
+ expect(b.destination_type).to eq("queue")
551
+ expect(b.source).to eq(x.name)
552
+ expect(b.routing_key).to_not be_nil
553
+ expect(b.properties_key).to_not be_nil
554
+ expect(b.vhost).to eq("/")
568
555
 
569
556
  q.delete
570
557
  x.delete
@@ -575,7 +562,7 @@ describe RabbitMQ::HTTP::Client do
575
562
  before :all do
576
563
  @channel = @connection.create_channel
577
564
  end
578
-
565
+
579
566
  it "creates a binding between an exchange and a queue" do
580
567
  routing_key = 'test.key'
581
568
  q = @channel.queue("")
@@ -584,7 +571,7 @@ describe RabbitMQ::HTTP::Client do
584
571
 
585
572
  b = subject.bind_queue("/", q.name, x.name, routing_key)
586
573
 
587
- b.should == q.name + "/" + routing_key
574
+ expect(b).to eq(q.name + "/" + routing_key)
588
575
 
589
576
  q.delete
590
577
  x.delete
@@ -604,11 +591,11 @@ describe RabbitMQ::HTTP::Client do
604
591
 
605
592
  xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
606
593
  b1 = xs.first
607
-
594
+
608
595
  b2 = subject.queue_binding_info("/", q.name, x.name, b1.properties_key)
609
-
610
- b1.should == b2
611
-
596
+
597
+ expect(b1).to eq(b2)
598
+
612
599
  end
613
600
  end
614
601
 
@@ -616,7 +603,7 @@ describe RabbitMQ::HTTP::Client do
616
603
  before :all do
617
604
  @channel = @connection.create_channel
618
605
  end
619
-
606
+
620
607
  it "deletes an individual binding between an exchange and a queue" do
621
608
  routing_key = 'test.key'
622
609
  q = @channel.queue("")
@@ -625,12 +612,12 @@ describe RabbitMQ::HTTP::Client do
625
612
 
626
613
  xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
627
614
  b = xs.first
628
-
629
- subject.delete_queue_binding("/", q.name, x.name, b.properties_key).should be_true
615
+
616
+ expect(subject.delete_queue_binding("/", q.name, x.name, b.properties_key)).to eq(true)
630
617
 
631
618
  xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
632
-
633
- xs.size.should == 0
619
+
620
+ expect(xs.size).to eq(0)
634
621
 
635
622
  q.delete
636
623
  x.delete
@@ -642,8 +629,8 @@ describe RabbitMQ::HTTP::Client do
642
629
  xs = subject.list_vhosts
643
630
  v = xs.first
644
631
 
645
- v.name.should_not be_nil
646
- v.tracing.should be_false
632
+ expect(v.name).to_not be_nil
633
+ expect(v.tracing).to eq(false)
647
634
  end
648
635
  end
649
636
 
@@ -652,16 +639,16 @@ describe RabbitMQ::HTTP::Client do
652
639
  it "returns infomation about a vhost" do
653
640
  v = subject.vhost_info("/")
654
641
 
655
- v.name.should_not be_nil
656
- v.tracing.should be_false
642
+ expect(v.name).to_not be_nil
643
+ expect(v.tracing).to eq(false)
657
644
  end
658
645
  end
659
646
 
660
647
  context "when vhost DOES NOT exist" do
661
648
  it "raises NotFound" do
662
- lambda do
649
+ expect do
663
650
  subject.vhost_info(Time.now.to_i.to_s)
664
- end.should raise_error(Faraday::Error::ResourceNotFound)
651
+ end.to raise_error(Faraday::Error::ResourceNotFound)
665
652
  end
666
653
  end
667
654
 
@@ -692,7 +679,7 @@ describe RabbitMQ::HTTP::Client do
692
679
  subject.create_vhost(vhost)
693
680
 
694
681
  v = subject.vhost_info(vhost)
695
- v.name.should == vhost
682
+ expect(v.name).to eq(vhost)
696
683
 
697
684
  subject.delete_vhost(v.name)
698
685
  end
@@ -708,7 +695,7 @@ describe RabbitMQ::HTTP::Client do
708
695
  subject.create_vhost(vhost)
709
696
 
710
697
  v = subject.vhost_info(vhost)
711
- v.name.should == vhost
698
+ expect(v.name).to eq(vhost)
712
699
 
713
700
  subject.delete_vhost(v.name)
714
701
  end
@@ -730,7 +717,7 @@ describe RabbitMQ::HTTP::Client do
730
717
  xs = subject.list_permissions("/")
731
718
  p = xs.detect { |x| x.user == "guest" }
732
719
 
733
- p.read.should == ".*"
720
+ expect(p.read).to eq(".*")
734
721
  end
735
722
  end
736
723
 
@@ -739,17 +726,17 @@ describe RabbitMQ::HTTP::Client do
739
726
  xs = subject.list_users
740
727
  u = xs.first
741
728
 
742
- u.name.should_not be_nil
743
- u.password_hash.should_not be_nil
744
- u.tags.should_not be_nil
729
+ expect(u.name).to_not be_nil
730
+ expect(u.password_hash).to_not be_nil
731
+ expect(u.tags).to_not be_nil
745
732
  end
746
733
  end
747
734
 
748
735
  describe "GET /api/users/:name" do
749
736
  it "returns information about a user" do
750
737
  u = subject.user_info("guest")
751
- u.name.should == "guest"
752
- u.tags.should == "administrator"
738
+ expect(u.name).to eq("guest")
739
+ expect(u.tags).to eq("administrator")
753
740
  end
754
741
  end
755
742
 
@@ -758,7 +745,7 @@ describe RabbitMQ::HTTP::Client do
758
745
  subject.update_user("alt", :tags => "http, policymaker, management", :password => "alt")
759
746
 
760
747
  u = subject.user_info("alt")
761
- u.tags.should == "http,policymaker,management"
748
+ expect(u.tags).to eq("http,policymaker,management")
762
749
  end
763
750
  end
764
751
 
@@ -774,21 +761,21 @@ describe RabbitMQ::HTTP::Client do
774
761
  xs = subject.user_permissions("guest")
775
762
  p = xs.first
776
763
 
777
- p.read.should == ".*"
764
+ expect(p.read).to eq(".*")
778
765
  end
779
766
  end
780
767
 
781
768
  describe "GET /api/whoami" do
782
769
  it "returns information about the current user" do
783
770
  u = subject.whoami
784
- u.name.should == "guest"
771
+ expect(u.name).to eq("guest")
785
772
  end
786
773
  end
787
774
 
788
775
  describe "GET /api/permissions" do
789
776
  it "lists all permissions" do
790
777
  xs = subject.list_permissions
791
- xs.first.read.should_not be_nil
778
+ expect(xs.first.read).to_not be_nil
792
779
  end
793
780
  end
794
781
 
@@ -796,9 +783,9 @@ describe RabbitMQ::HTTP::Client do
796
783
  it "returns a list of permissions of a user in a vhost" do
797
784
  p = subject.list_permissions_of("/", "guest")
798
785
 
799
- p.read.should == ".*"
800
- p.write.should == ".*"
801
- p.configure.should == ".*"
786
+ expect(p.read).to eq(".*")
787
+ expect(p.write).to eq(".*")
788
+ expect(p.configure).to eq(".*")
802
789
  end
803
790
  end
804
791
 
@@ -808,9 +795,9 @@ describe RabbitMQ::HTTP::Client do
808
795
 
809
796
  p = subject.list_permissions_of("/", "guest")
810
797
 
811
- p.read.should == ".*"
812
- p.write.should == ".*"
813
- p.configure.should == ".*"
798
+ expect(p.read).to eq(".*")
799
+ expect(p.write).to eq(".*")
800
+ expect(p.configure).to eq(".*")
814
801
  end
815
802
  end
816
803
 
@@ -834,7 +821,7 @@ describe RabbitMQ::HTTP::Client do
834
821
  describe "GET /api/parameters" do
835
822
  it "returns a list of all parameters" do
836
823
  xs = subject.list_parameters
837
- xs.should be_kind_of(Array)
824
+ expect(xs).to be_kind_of(Array)
838
825
  end
839
826
  end
840
827
 
@@ -846,14 +833,14 @@ describe RabbitMQ::HTTP::Client do
846
833
  describe "GET /api/policies" do
847
834
  it "returns a list of all policies" do
848
835
  xs = subject.list_policies
849
- xs.should be_kind_of(Array)
836
+ expect(xs).to be_kind_of(Array)
850
837
  end
851
838
  end
852
839
 
853
840
  describe "GET /api/policies/:vhost" do
854
841
  it "returns a list of all policies in a vhost" do
855
842
  xs = subject.list_policies("/")
856
- xs.should be_kind_of(Array)
843
+ expect(xs).to be_kind_of(Array)
857
844
  end
858
845
  end
859
846
 
@@ -866,7 +853,7 @@ describe RabbitMQ::HTTP::Client do
866
853
  it "performs aliveness check" do
867
854
  r = subject.aliveness_test("/")
868
855
 
869
- r.should be_true
856
+ expect(r).to eq(true)
870
857
  end
871
858
  end
872
859
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbitmq_http_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klishin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie