wamp_client 0.0.2 → 0.0.3

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: 150daa5402442aaf1557dda7501439fa35266669
4
- data.tar.gz: 72d8de49f166b98d2688c2602857c3eef5cbb07d
3
+ metadata.gz: 18eebe1e1f311e163994660dc5a2715b7b53dcab
4
+ data.tar.gz: c5361e2bc04b8b941b778b8759f33f3ca6bbb0a9
5
5
  SHA512:
6
- metadata.gz: a16f76680f8b99352b8321729f9f538d40db5b5d208c864e1d6770cd89e31b9733a8b72bd1378321fe83523bd1829720b1e772ee12a2b6430ba7c76ca290379a
7
- data.tar.gz: 986f7e28cd8773a040778704e28ca4c8f47f213157073f8bd51116599c2da0b70a42989decf524384f9b8374d1a6890b26b02beeace5ec1831c377371d5c072f
6
+ metadata.gz: 7bcff7ef4a7d3efa480e89195327abc130346db5240855ce933f4423e0ef26f4843648de87b777f204804bcf4a54a037c89c56c60f42fe10771d0943b52c07c0
7
+ data.tar.gz: 1ab9e3adb1d6ea818996a76c9c884c09e1921cf582daaa194cf6f37ed86679270fcce129bab4d23f1184922373c5e5780ebd2f9bed2f36b0635e4a631735df17
data/README.md CHANGED
@@ -10,6 +10,8 @@ Client for talking to a WAMP Router. This is defined at
10
10
 
11
11
  ## Revision History
12
12
 
13
+ - v0.0.3:
14
+ - Fixed issue 1: Empty args will omit kwargs on some message types
13
15
  - v0.0.2:
14
16
  - Added defer call result support
15
17
  - Added progressive callee support
@@ -88,7 +90,7 @@ connection.close
88
90
  Note that the connection will still call "on_leave" and "on_disconnect" as it closes the session and the transport
89
91
 
90
92
  #### Callbacks
91
- A session has the following callbacks
93
+ A connection has the following callbacks
92
94
 
93
95
  **on_connect** - Called when the transport is opened
94
96
  ```ruby
@@ -118,7 +120,7 @@ connection.on_disconnect do |reason|
118
120
  end
119
121
  ```
120
122
 
121
- **oon_challenge** - Called when an authentication challenge is created
123
+ **on_challenge** - Called when an authentication challenge is created
122
124
  ```ruby
123
125
  connection.on_challenge do |authmethod, extra|
124
126
 
@@ -215,7 +217,7 @@ end
215
217
  This method subscribes to a topic. The prototype for the method is
216
218
 
217
219
  ```ruby
218
- subscribe(topic, handler, options={}, &callback)
220
+ def subscribe(topic, handler, options={}, &callback)
219
221
  ```
220
222
 
221
223
  where the parameters are defined as
@@ -288,7 +290,7 @@ session.unsubscribe(@subscription)
288
290
  This method publishes an event to all of the subscribers. The prototype for the method is
289
291
 
290
292
  ```ruby
291
- publish(topic, args=nil, kwargs=nil, options={}, &callback)
293
+ def publish(topic, args=nil, kwargs=nil, options={}, &callback)
292
294
  ```
293
295
 
294
296
  where the parameters are defined as
@@ -331,7 +333,7 @@ Options are
331
333
  This method registers to a procedure. The prototype for the method is
332
334
 
333
335
  ```ruby
334
- register(procedure, handler, options={}, &callback)
336
+ def register(procedure, handler, options={}, &callback)
335
337
  ```
336
338
 
337
339
  where the parameters are defined as
@@ -406,7 +408,7 @@ session.unregister(@registration)
406
408
  This method calls a procedure. The prototype for the method is
407
409
 
408
410
  ```ruby
409
- call(procedure, args=nil, kwargs=nil, options={}, &callback)
411
+ def call(procedure, args=nil, kwargs=nil, options={}, &callback)
410
412
  ```
411
413
 
412
414
  where the parameters are defined as
@@ -500,10 +502,10 @@ def add(args, kwargs, details)
500
502
  defer.progress(WampClient::CallResult.new([1,2,3]))
501
503
  }
502
504
  EM.add_timer(4) { # Something Async
503
- defer.progress(WampClient::CallResult.new([1,2,3]))
505
+ defer.progress(WampClient::CallResult.new([4,5,6]))
504
506
  }
505
507
  EM.add_timer(6) { # Something Async
506
- defer.succeed(WampClient::CallResult.new())
508
+ defer.succeed(WampClient::CallResult.new)
507
509
  }
508
510
  defer
509
511
  end
@@ -520,7 +522,6 @@ session.register('com.example.procedure', method(:add))
520
522
 
521
523
  ### TODOs
522
524
 
523
- - progressive_call_results (callee)
524
525
  - call_timeout
525
526
  - call_canceling
526
527
 
@@ -156,6 +156,7 @@ module WampClient
156
156
  end
157
157
 
158
158
  def payload
159
+
159
160
  payload = [self.class.type]
160
161
  payload.push(self.realm)
161
162
  payload.push(self.details)
@@ -201,6 +202,7 @@ module WampClient
201
202
  end
202
203
 
203
204
  def payload
205
+
204
206
  payload = [self.class.type]
205
207
  payload.push(self.session)
206
208
  payload.push(self.details)
@@ -246,6 +248,7 @@ module WampClient
246
248
  end
247
249
 
248
250
  def payload
251
+
249
252
  payload = [self.class.type]
250
253
  payload.push(self.details)
251
254
  payload.push(self.reason)
@@ -291,6 +294,7 @@ module WampClient
291
294
  end
292
295
 
293
296
  def payload
297
+
294
298
  payload = [self.class.type]
295
299
  payload.push(self.details)
296
300
  payload.push(self.reason)
@@ -346,16 +350,19 @@ module WampClient
346
350
  end
347
351
 
348
352
  def payload
353
+ self.arguments ||= []
354
+ self.argumentskw ||= {}
355
+
349
356
  payload = [self.class.type]
350
357
  payload.push(self.request_type)
351
358
  payload.push(self.request_request)
352
359
  payload.push(self.details)
353
360
  payload.push(self.error)
354
361
 
355
- return payload if (self.arguments.nil? or self.arguments.empty?)
362
+ return payload if (self.arguments.empty? and self.argumentskw.empty?)
356
363
  payload.push(self.arguments)
357
364
 
358
- return payload if (self.argumentskw.nil? or self.argumentskw.empty?)
365
+ return payload if (self.argumentskw.empty?)
359
366
  payload.push(self.argumentskw)
360
367
 
361
368
  payload
@@ -407,15 +414,18 @@ module WampClient
407
414
  end
408
415
 
409
416
  def payload
417
+ self.arguments ||= []
418
+ self.argumentskw ||= {}
419
+
410
420
  payload = [self.class.type]
411
421
  payload.push(self.request)
412
422
  payload.push(self.options)
413
423
  payload.push(self.topic)
414
424
 
415
- return payload if (self.arguments.nil? or self.arguments.empty?)
425
+ return payload if (self.arguments.empty? and self.argumentskw.empty?)
416
426
  payload.push(self.arguments)
417
427
 
418
- return payload if (self.argumentskw.nil? or self.argumentskw.empty?)
428
+ return payload if (self.argumentskw.empty?)
419
429
  payload.push(self.argumentskw)
420
430
 
421
431
  payload
@@ -459,6 +469,7 @@ module WampClient
459
469
  end
460
470
 
461
471
  def payload
472
+
462
473
  payload = [self.class.type]
463
474
  payload.push(self.publish_request)
464
475
  payload.push(self.publication)
@@ -506,6 +517,7 @@ module WampClient
506
517
  end
507
518
 
508
519
  def payload
520
+
509
521
  payload = [self.class.type]
510
522
  payload.push(self.request)
511
523
  payload.push(self.options)
@@ -552,6 +564,7 @@ module WampClient
552
564
  end
553
565
 
554
566
  def payload
567
+
555
568
  payload = [self.class.type]
556
569
  payload.push(self.subscribe_request)
557
570
  payload.push(self.subscription)
@@ -597,6 +610,7 @@ module WampClient
597
610
  end
598
611
 
599
612
  def payload
613
+
600
614
  payload = [self.class.type]
601
615
  payload.push(self.request)
602
616
  payload.push(self.subscribed_subscription)
@@ -640,6 +654,7 @@ module WampClient
640
654
  end
641
655
 
642
656
  def payload
657
+
643
658
  payload = [self.class.type]
644
659
  payload.push(self.unsubscribe_request)
645
660
 
@@ -692,15 +707,18 @@ module WampClient
692
707
  end
693
708
 
694
709
  def payload
710
+ self.publish_arguments ||= []
711
+ self.publish_argumentskw ||= {}
712
+
695
713
  payload = [self.class.type]
696
714
  payload.push(self.subscribed_subscription)
697
715
  payload.push(self.published_publication)
698
716
  payload.push(self.details)
699
717
 
700
- return payload if (self.publish_arguments.nil? or self.publish_arguments.empty?)
718
+ return payload if (self.publish_arguments.empty? and self.publish_argumentskw.empty?)
701
719
  payload.push(self.publish_arguments)
702
720
 
703
- return payload if (self.publish_argumentskw.nil? or self.publish_argumentskw.empty?)
721
+ return payload if (self.publish_argumentskw.empty?)
704
722
  payload.push(self.publish_argumentskw)
705
723
 
706
724
  payload
@@ -752,15 +770,18 @@ module WampClient
752
770
  end
753
771
 
754
772
  def payload
773
+ self.arguments ||= []
774
+ self.argumentskw ||= {}
775
+
755
776
  payload = [self.class.type]
756
777
  payload.push(self.request)
757
778
  payload.push(self.options)
758
779
  payload.push(self.procedure)
759
780
 
760
- return payload if (self.arguments.nil? or self.arguments.empty?)
781
+ return payload if (self.arguments.empty? and self.argumentskw.empty?)
761
782
  payload.push(self.arguments)
762
783
 
763
- return payload if (self.argumentskw.nil? or self.argumentskw.empty?)
784
+ return payload if (self.argumentskw.empty?)
764
785
  payload.push(self.argumentskw)
765
786
 
766
787
  payload
@@ -810,14 +831,17 @@ module WampClient
810
831
  end
811
832
 
812
833
  def payload
834
+ self.yield_arguments ||= []
835
+ self.yield_argumentskw ||= {}
836
+
813
837
  payload = [self.class.type]
814
838
  payload.push(self.call_request)
815
839
  payload.push(self.details)
816
840
 
817
- return payload if (self.yield_arguments.nil? or self.yield_arguments.empty?)
841
+ return payload if (self.yield_arguments.empty? and self.yield_argumentskw.empty?)
818
842
  payload.push(self.yield_arguments)
819
843
 
820
- return payload if (self.yield_argumentskw.nil? or self.yield_argumentskw.empty?)
844
+ return payload if (self.yield_argumentskw.empty?)
821
845
  payload.push(self.yield_argumentskw)
822
846
 
823
847
  payload
@@ -863,6 +887,7 @@ module WampClient
863
887
  end
864
888
 
865
889
  def payload
890
+
866
891
  payload = [self.class.type]
867
892
  payload.push(self.request)
868
893
  payload.push(self.options)
@@ -909,6 +934,7 @@ module WampClient
909
934
  end
910
935
 
911
936
  def payload
937
+
912
938
  payload = [self.class.type]
913
939
  payload.push(self.register_request)
914
940
  payload.push(self.registration)
@@ -954,6 +980,7 @@ module WampClient
954
980
  end
955
981
 
956
982
  def payload
983
+
957
984
  payload = [self.class.type]
958
985
  payload.push(self.request)
959
986
  payload.push(self.registered_registration)
@@ -997,6 +1024,7 @@ module WampClient
997
1024
  end
998
1025
 
999
1026
  def payload
1027
+
1000
1028
  payload = [self.class.type]
1001
1029
  payload.push(self.unregister_request)
1002
1030
 
@@ -1049,15 +1077,18 @@ module WampClient
1049
1077
  end
1050
1078
 
1051
1079
  def payload
1080
+ self.call_arguments ||= []
1081
+ self.call_argumentskw ||= {}
1082
+
1052
1083
  payload = [self.class.type]
1053
1084
  payload.push(self.request)
1054
1085
  payload.push(self.registered_registration)
1055
1086
  payload.push(self.details)
1056
1087
 
1057
- return payload if (self.call_arguments.nil? or self.call_arguments.empty?)
1088
+ return payload if (self.call_arguments.empty? and self.call_argumentskw.empty?)
1058
1089
  payload.push(self.call_arguments)
1059
1090
 
1060
- return payload if (self.call_argumentskw.nil? or self.call_argumentskw.empty?)
1091
+ return payload if (self.call_argumentskw.empty?)
1061
1092
  payload.push(self.call_argumentskw)
1062
1093
 
1063
1094
  payload
@@ -1107,14 +1138,17 @@ module WampClient
1107
1138
  end
1108
1139
 
1109
1140
  def payload
1141
+ self.arguments ||= []
1142
+ self.argumentskw ||= {}
1143
+
1110
1144
  payload = [self.class.type]
1111
1145
  payload.push(self.invocation_request)
1112
1146
  payload.push(self.options)
1113
1147
 
1114
- return payload if (self.arguments.nil? or self.arguments.empty?)
1148
+ return payload if (self.arguments.empty? and self.argumentskw.empty?)
1115
1149
  payload.push(self.arguments)
1116
1150
 
1117
- return payload if (self.argumentskw.nil? or self.argumentskw.empty?)
1151
+ return payload if (self.argumentskw.empty?)
1118
1152
  payload.push(self.argumentskw)
1119
1153
 
1120
1154
  payload
@@ -1158,6 +1192,7 @@ module WampClient
1158
1192
  end
1159
1193
 
1160
1194
  def payload
1195
+
1161
1196
  payload = [self.class.type]
1162
1197
  payload.push(self.authmethod)
1163
1198
  payload.push(self.extra)
@@ -1203,6 +1238,7 @@ module WampClient
1203
1238
  end
1204
1239
 
1205
1240
  def payload
1241
+
1206
1242
  payload = [self.class.type]
1207
1243
  payload.push(self.signature)
1208
1244
  payload.push(self.extra)
@@ -1248,6 +1284,7 @@ module WampClient
1248
1284
  end
1249
1285
 
1250
1286
  def payload
1287
+
1251
1288
  payload = [self.class.type]
1252
1289
  payload.push(self.call_request)
1253
1290
  payload.push(self.options)
@@ -1293,6 +1330,7 @@ module WampClient
1293
1330
  end
1294
1331
 
1295
1332
  def payload
1333
+
1296
1334
  payload = [self.class.type]
1297
1335
  payload.push(self.invocation_request)
1298
1336
  payload.push(self.options)
@@ -1307,4 +1345,4 @@ module WampClient
1307
1345
  end
1308
1346
 
1309
1347
  end
1310
- end
1348
+ end
@@ -26,5 +26,5 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
26
  =end
27
27
 
28
28
  module WampClient
29
- VERSION = '0.0.2'
29
+ VERSION = '0.0.3'
30
30
  end
@@ -18,6 +18,24 @@ def value_from_type(type)
18
18
 
19
19
  end
20
20
 
21
+ def empty_value_from_type(type)
22
+
23
+ value = nil
24
+
25
+ if type == 'int' or type == 'id'
26
+ value = '0'
27
+ elsif type == 'uri' or type == 'string'
28
+ value = "''"
29
+ elsif type == 'list'
30
+ value = "[]"
31
+ elsif type == 'dict'
32
+ value = '{}'
33
+ end
34
+
35
+ value
36
+
37
+ end
38
+
21
39
  message_type_lookup = {
22
40
  'HELLO' => 1,
23
41
  'WELCOME' => 2,
@@ -401,12 +419,31 @@ messages.each do |message|
401
419
 
402
420
  # Generate the payload
403
421
  source_file += "\n def payload\n"
422
+
423
+ optional_params = []
424
+ params.each do |param|
425
+ unless param[:required]
426
+ optional_params.push(param)
427
+ source_file += " self.#{param[:name]} ||= #{empty_value_from_type(param[:type])}\n"
428
+ end
429
+ end
430
+ source_file += "\n"
431
+
404
432
  source_file += " payload = [self.class.type]\n"
433
+ optional_count = 0
405
434
  params.each do |param|
406
435
  if param[:required]
407
436
  source_file += " payload.push(self.#{param[:name]})\n"
408
437
  else
409
- source_file += "\n return payload if (self.#{param[:name]}.nil? or self.#{param[:name]}.empty?)\n"
438
+ optional_count += 1
439
+ source_file += "\n return payload if (self.#{param[:name]}.empty?"
440
+
441
+ # Insert remaining parameters
442
+ for i in optional_count..(optional_params.size-1) do
443
+ source_file += " and self.#{optional_params[i][:name]}.empty?"
444
+ end
445
+
446
+ source_file += ")\n"
410
447
  source_file += " payload.push(self.#{param[:name]})\n"
411
448
  end
412
449
  end
@@ -486,45 +523,95 @@ messages.each do |message|
486
523
  end
487
524
  test_file += " end\n"
488
525
 
526
+ number_of_optional_params = 0
527
+
489
528
  # Generate non-required parameter tests
490
529
  params.each do |param|
491
530
  unless param[:required]
492
- value_array.push(value_from_type(param[:type]))
531
+ number_of_optional_params += 1
532
+
533
+ temp_value_array = Array.new(value_array)
534
+ temp_value_array.push(value_from_type(param[:type]))
493
535
 
494
536
  test_file += "\n describe 'checks optional parameter #{param[:name]}' do\n"
495
537
 
496
538
  # Generate Constructor Test
497
539
  test_file += "\n it 'creates the message object' do\n"
498
- test_file += " params = [#{value_array.join(',')}]\n"
540
+ test_file += " params = [#{temp_value_array.join(',')}]\n"
499
541
  test_file += " object = #{class_name}.new(*params)\n\n"
500
542
  test_file += " expect(object.is_a?(#{class_name})).to eq(true)\n"
501
543
  test_file += " end\n"
502
544
 
503
545
  # Generate Parser Test
504
546
  test_file += "\n it 'parses the message and creates an object' do\n"
505
- test_file += " params = [#{message_type_lookup[message[:name].upcase]},#{value_array.join(',')}]\n"
547
+ test_file += " params = [#{message_type_lookup[message[:name].upcase]},#{temp_value_array.join(',')}]\n"
506
548
  test_file += " object = #{class_name}.parse(params)\n\n"
507
549
  test_file += " expect(object.is_a?(#{class_name})).to eq(true)\n"
508
550
  test_file += " end\n"
509
551
 
510
552
  # Generate Payload Test
511
553
  test_file += "\n it 'generates the payload' do\n"
512
- test_file += " params = [#{value_array.join(',')}]\n"
554
+ test_file += " params = [#{temp_value_array.join(',')}]\n"
513
555
  test_file += " object = #{class_name}.new(*params)\n"
514
556
  test_file += " payload = object.payload\n\n"
515
557
  count = 0
516
- test_file += " expect(payload.count).to eq(#{value_array.count+1})\n"
558
+ test_file += " expect(payload.count).to eq(#{temp_value_array.count+1})\n"
517
559
  test_file += " expect(payload[0]).to eq(#{message_type_lookup[message[:name].upcase]})\n"
518
- value_array.each do |value|
560
+ temp_value_array.each do |value|
519
561
  test_file += " expect(payload[#{count+1}]).to eq(#{value})\n"
520
562
  count += 1
521
563
  end
522
564
  test_file += " end\n"
523
565
 
524
566
  test_file += "\n end\n"
567
+
568
+ value_array.push(empty_value_from_type(param[:type]))
525
569
  end
526
570
  end
527
571
 
572
+ ## Test the final one and make sure they omit
573
+ if number_of_optional_params > 0
574
+
575
+ # Generate check params
576
+ check_params = []
577
+ for i in 0..(value_array.size-number_of_optional_params-1) do
578
+ check_params.push(value_array[i])
579
+ end
580
+
581
+ test_file += "\n describe 'checks optional parameters' do\n"
582
+
583
+ # Generate Constructor Test
584
+ test_file += "\n it 'creates the message object' do\n"
585
+ test_file += " params = [#{value_array.join(',')}]\n"
586
+ test_file += " object = #{class_name}.new(*params)\n\n"
587
+ test_file += " expect(object.is_a?(#{class_name})).to eq(true)\n"
588
+ test_file += " end\n"
589
+
590
+ # Generate Parser Test
591
+ test_file += "\n it 'parses the message and creates an object' do\n"
592
+ test_file += " params = [#{message_type_lookup[message[:name].upcase]},#{value_array.join(',')}]\n"
593
+ test_file += " object = #{class_name}.parse(params)\n\n"
594
+ test_file += " expect(object.is_a?(#{class_name})).to eq(true)\n"
595
+ test_file += " end\n"
596
+
597
+ # Generate Payload Test
598
+ test_file += "\n it 'generates the payload' do\n"
599
+ test_file += " params = [#{value_array.join(',')}]\n"
600
+ test_file += " object = #{class_name}.new(*params)\n"
601
+ test_file += " payload = object.payload\n\n"
602
+ count = 0
603
+ test_file += " expect(payload.count).to eq(#{check_params.count+1})\n"
604
+ test_file += " expect(payload[0]).to eq(#{message_type_lookup[message[:name].upcase]})\n"
605
+ check_params.each do |value|
606
+ test_file += " expect(payload[#{count+1}]).to eq(#{value})\n"
607
+ count += 1
608
+ end
609
+ test_file += " end\n"
610
+
611
+ test_file += "\n end\n"
612
+
613
+ end
614
+
528
615
  test_file += "\n end\n"
529
616
 
530
617
  end
data/spec/message_spec.rb CHANGED
@@ -255,21 +255,21 @@ describe WampClient::Message do
255
255
  describe 'checks optional parameter argumentskw' do
256
256
 
257
257
  it 'creates the message object' do
258
- params = [123,123,{ test: 1 },'string',['test'],{ test: 1 }]
258
+ params = [123,123,{ test: 1 },'string',[],{ test: 1 }]
259
259
  object = WampClient::Message::Error.new(*params)
260
260
 
261
261
  expect(object.is_a?(WampClient::Message::Error)).to eq(true)
262
262
  end
263
263
 
264
264
  it 'parses the message and creates an object' do
265
- params = [8,123,123,{ test: 1 },'string',['test'],{ test: 1 }]
265
+ params = [8,123,123,{ test: 1 },'string',[],{ test: 1 }]
266
266
  object = WampClient::Message::Error.parse(params)
267
267
 
268
268
  expect(object.is_a?(WampClient::Message::Error)).to eq(true)
269
269
  end
270
270
 
271
271
  it 'generates the payload' do
272
- params = [123,123,{ test: 1 },'string',['test'],{ test: 1 }]
272
+ params = [123,123,{ test: 1 },'string',[],{ test: 1 }]
273
273
  object = WampClient::Message::Error.new(*params)
274
274
  payload = object.payload
275
275
 
@@ -279,12 +279,43 @@ describe WampClient::Message do
279
279
  expect(payload[2]).to eq(123)
280
280
  expect(payload[3]).to eq({ test: 1 })
281
281
  expect(payload[4]).to eq('string')
282
- expect(payload[5]).to eq(['test'])
282
+ expect(payload[5]).to eq([])
283
283
  expect(payload[6]).to eq({ test: 1 })
284
284
  end
285
285
 
286
286
  end
287
287
 
288
+ describe 'checks optional parameters' do
289
+
290
+ it 'creates the message object' do
291
+ params = [123,123,{ test: 1 },'string',[],{}]
292
+ object = WampClient::Message::Error.new(*params)
293
+
294
+ expect(object.is_a?(WampClient::Message::Error)).to eq(true)
295
+ end
296
+
297
+ it 'parses the message and creates an object' do
298
+ params = [8,123,123,{ test: 1 },'string',[],{}]
299
+ object = WampClient::Message::Error.parse(params)
300
+
301
+ expect(object.is_a?(WampClient::Message::Error)).to eq(true)
302
+ end
303
+
304
+ it 'generates the payload' do
305
+ params = [123,123,{ test: 1 },'string',[],{}]
306
+ object = WampClient::Message::Error.new(*params)
307
+ payload = object.payload
308
+
309
+ expect(payload.count).to eq(5)
310
+ expect(payload[0]).to eq(8)
311
+ expect(payload[1]).to eq(123)
312
+ expect(payload[2]).to eq(123)
313
+ expect(payload[3]).to eq({ test: 1 })
314
+ expect(payload[4]).to eq('string')
315
+ end
316
+
317
+ end
318
+
288
319
  end
289
320
 
290
321
  describe WampClient::Message::Publish do
@@ -365,21 +396,21 @@ describe WampClient::Message do
365
396
  describe 'checks optional parameter argumentskw' do
366
397
 
367
398
  it 'creates the message object' do
368
- params = [123,{ test: 1 },'string',['test'],{ test: 1 }]
399
+ params = [123,{ test: 1 },'string',[],{ test: 1 }]
369
400
  object = WampClient::Message::Publish.new(*params)
370
401
 
371
402
  expect(object.is_a?(WampClient::Message::Publish)).to eq(true)
372
403
  end
373
404
 
374
405
  it 'parses the message and creates an object' do
375
- params = [16,123,{ test: 1 },'string',['test'],{ test: 1 }]
406
+ params = [16,123,{ test: 1 },'string',[],{ test: 1 }]
376
407
  object = WampClient::Message::Publish.parse(params)
377
408
 
378
409
  expect(object.is_a?(WampClient::Message::Publish)).to eq(true)
379
410
  end
380
411
 
381
412
  it 'generates the payload' do
382
- params = [123,{ test: 1 },'string',['test'],{ test: 1 }]
413
+ params = [123,{ test: 1 },'string',[],{ test: 1 }]
383
414
  object = WampClient::Message::Publish.new(*params)
384
415
  payload = object.payload
385
416
 
@@ -388,12 +419,42 @@ describe WampClient::Message do
388
419
  expect(payload[1]).to eq(123)
389
420
  expect(payload[2]).to eq({ test: 1 })
390
421
  expect(payload[3]).to eq('string')
391
- expect(payload[4]).to eq(['test'])
422
+ expect(payload[4]).to eq([])
392
423
  expect(payload[5]).to eq({ test: 1 })
393
424
  end
394
425
 
395
426
  end
396
427
 
428
+ describe 'checks optional parameters' do
429
+
430
+ it 'creates the message object' do
431
+ params = [123,{ test: 1 },'string',[],{}]
432
+ object = WampClient::Message::Publish.new(*params)
433
+
434
+ expect(object.is_a?(WampClient::Message::Publish)).to eq(true)
435
+ end
436
+
437
+ it 'parses the message and creates an object' do
438
+ params = [16,123,{ test: 1 },'string',[],{}]
439
+ object = WampClient::Message::Publish.parse(params)
440
+
441
+ expect(object.is_a?(WampClient::Message::Publish)).to eq(true)
442
+ end
443
+
444
+ it 'generates the payload' do
445
+ params = [123,{ test: 1 },'string',[],{}]
446
+ object = WampClient::Message::Publish.new(*params)
447
+ payload = object.payload
448
+
449
+ expect(payload.count).to eq(4)
450
+ expect(payload[0]).to eq(16)
451
+ expect(payload[1]).to eq(123)
452
+ expect(payload[2]).to eq({ test: 1 })
453
+ expect(payload[3]).to eq('string')
454
+ end
455
+
456
+ end
457
+
397
458
  end
398
459
 
399
460
  describe WampClient::Message::Published do
@@ -684,21 +745,21 @@ describe WampClient::Message do
684
745
  describe 'checks optional parameter publish_argumentskw' do
685
746
 
686
747
  it 'creates the message object' do
687
- params = [123,123,{ test: 1 },['test'],{ test: 1 }]
748
+ params = [123,123,{ test: 1 },[],{ test: 1 }]
688
749
  object = WampClient::Message::Event.new(*params)
689
750
 
690
751
  expect(object.is_a?(WampClient::Message::Event)).to eq(true)
691
752
  end
692
753
 
693
754
  it 'parses the message and creates an object' do
694
- params = [36,123,123,{ test: 1 },['test'],{ test: 1 }]
755
+ params = [36,123,123,{ test: 1 },[],{ test: 1 }]
695
756
  object = WampClient::Message::Event.parse(params)
696
757
 
697
758
  expect(object.is_a?(WampClient::Message::Event)).to eq(true)
698
759
  end
699
760
 
700
761
  it 'generates the payload' do
701
- params = [123,123,{ test: 1 },['test'],{ test: 1 }]
762
+ params = [123,123,{ test: 1 },[],{ test: 1 }]
702
763
  object = WampClient::Message::Event.new(*params)
703
764
  payload = object.payload
704
765
 
@@ -707,12 +768,42 @@ describe WampClient::Message do
707
768
  expect(payload[1]).to eq(123)
708
769
  expect(payload[2]).to eq(123)
709
770
  expect(payload[3]).to eq({ test: 1 })
710
- expect(payload[4]).to eq(['test'])
771
+ expect(payload[4]).to eq([])
711
772
  expect(payload[5]).to eq({ test: 1 })
712
773
  end
713
774
 
714
775
  end
715
776
 
777
+ describe 'checks optional parameters' do
778
+
779
+ it 'creates the message object' do
780
+ params = [123,123,{ test: 1 },[],{}]
781
+ object = WampClient::Message::Event.new(*params)
782
+
783
+ expect(object.is_a?(WampClient::Message::Event)).to eq(true)
784
+ end
785
+
786
+ it 'parses the message and creates an object' do
787
+ params = [36,123,123,{ test: 1 },[],{}]
788
+ object = WampClient::Message::Event.parse(params)
789
+
790
+ expect(object.is_a?(WampClient::Message::Event)).to eq(true)
791
+ end
792
+
793
+ it 'generates the payload' do
794
+ params = [123,123,{ test: 1 },[],{}]
795
+ object = WampClient::Message::Event.new(*params)
796
+ payload = object.payload
797
+
798
+ expect(payload.count).to eq(4)
799
+ expect(payload[0]).to eq(36)
800
+ expect(payload[1]).to eq(123)
801
+ expect(payload[2]).to eq(123)
802
+ expect(payload[3]).to eq({ test: 1 })
803
+ end
804
+
805
+ end
806
+
716
807
  end
717
808
 
718
809
  describe WampClient::Message::Call do
@@ -793,21 +884,21 @@ describe WampClient::Message do
793
884
  describe 'checks optional parameter argumentskw' do
794
885
 
795
886
  it 'creates the message object' do
796
- params = [123,{ test: 1 },'string',['test'],{ test: 1 }]
887
+ params = [123,{ test: 1 },'string',[],{ test: 1 }]
797
888
  object = WampClient::Message::Call.new(*params)
798
889
 
799
890
  expect(object.is_a?(WampClient::Message::Call)).to eq(true)
800
891
  end
801
892
 
802
893
  it 'parses the message and creates an object' do
803
- params = [48,123,{ test: 1 },'string',['test'],{ test: 1 }]
894
+ params = [48,123,{ test: 1 },'string',[],{ test: 1 }]
804
895
  object = WampClient::Message::Call.parse(params)
805
896
 
806
897
  expect(object.is_a?(WampClient::Message::Call)).to eq(true)
807
898
  end
808
899
 
809
900
  it 'generates the payload' do
810
- params = [123,{ test: 1 },'string',['test'],{ test: 1 }]
901
+ params = [123,{ test: 1 },'string',[],{ test: 1 }]
811
902
  object = WampClient::Message::Call.new(*params)
812
903
  payload = object.payload
813
904
 
@@ -816,12 +907,42 @@ describe WampClient::Message do
816
907
  expect(payload[1]).to eq(123)
817
908
  expect(payload[2]).to eq({ test: 1 })
818
909
  expect(payload[3]).to eq('string')
819
- expect(payload[4]).to eq(['test'])
910
+ expect(payload[4]).to eq([])
820
911
  expect(payload[5]).to eq({ test: 1 })
821
912
  end
822
913
 
823
914
  end
824
915
 
916
+ describe 'checks optional parameters' do
917
+
918
+ it 'creates the message object' do
919
+ params = [123,{ test: 1 },'string',[],{}]
920
+ object = WampClient::Message::Call.new(*params)
921
+
922
+ expect(object.is_a?(WampClient::Message::Call)).to eq(true)
923
+ end
924
+
925
+ it 'parses the message and creates an object' do
926
+ params = [48,123,{ test: 1 },'string',[],{}]
927
+ object = WampClient::Message::Call.parse(params)
928
+
929
+ expect(object.is_a?(WampClient::Message::Call)).to eq(true)
930
+ end
931
+
932
+ it 'generates the payload' do
933
+ params = [123,{ test: 1 },'string',[],{}]
934
+ object = WampClient::Message::Call.new(*params)
935
+ payload = object.payload
936
+
937
+ expect(payload.count).to eq(4)
938
+ expect(payload[0]).to eq(48)
939
+ expect(payload[1]).to eq(123)
940
+ expect(payload[2]).to eq({ test: 1 })
941
+ expect(payload[3]).to eq('string')
942
+ end
943
+
944
+ end
945
+
825
946
  end
826
947
 
827
948
  describe WampClient::Message::Result do
@@ -897,21 +1018,21 @@ describe WampClient::Message do
897
1018
  describe 'checks optional parameter yield_argumentskw' do
898
1019
 
899
1020
  it 'creates the message object' do
900
- params = [123,{ test: 1 },['test'],{ test: 1 }]
1021
+ params = [123,{ test: 1 },[],{ test: 1 }]
901
1022
  object = WampClient::Message::Result.new(*params)
902
1023
 
903
1024
  expect(object.is_a?(WampClient::Message::Result)).to eq(true)
904
1025
  end
905
1026
 
906
1027
  it 'parses the message and creates an object' do
907
- params = [50,123,{ test: 1 },['test'],{ test: 1 }]
1028
+ params = [50,123,{ test: 1 },[],{ test: 1 }]
908
1029
  object = WampClient::Message::Result.parse(params)
909
1030
 
910
1031
  expect(object.is_a?(WampClient::Message::Result)).to eq(true)
911
1032
  end
912
1033
 
913
1034
  it 'generates the payload' do
914
- params = [123,{ test: 1 },['test'],{ test: 1 }]
1035
+ params = [123,{ test: 1 },[],{ test: 1 }]
915
1036
  object = WampClient::Message::Result.new(*params)
916
1037
  payload = object.payload
917
1038
 
@@ -919,12 +1040,41 @@ describe WampClient::Message do
919
1040
  expect(payload[0]).to eq(50)
920
1041
  expect(payload[1]).to eq(123)
921
1042
  expect(payload[2]).to eq({ test: 1 })
922
- expect(payload[3]).to eq(['test'])
1043
+ expect(payload[3]).to eq([])
923
1044
  expect(payload[4]).to eq({ test: 1 })
924
1045
  end
925
1046
 
926
1047
  end
927
1048
 
1049
+ describe 'checks optional parameters' do
1050
+
1051
+ it 'creates the message object' do
1052
+ params = [123,{ test: 1 },[],{}]
1053
+ object = WampClient::Message::Result.new(*params)
1054
+
1055
+ expect(object.is_a?(WampClient::Message::Result)).to eq(true)
1056
+ end
1057
+
1058
+ it 'parses the message and creates an object' do
1059
+ params = [50,123,{ test: 1 },[],{}]
1060
+ object = WampClient::Message::Result.parse(params)
1061
+
1062
+ expect(object.is_a?(WampClient::Message::Result)).to eq(true)
1063
+ end
1064
+
1065
+ it 'generates the payload' do
1066
+ params = [123,{ test: 1 },[],{}]
1067
+ object = WampClient::Message::Result.new(*params)
1068
+ payload = object.payload
1069
+
1070
+ expect(payload.count).to eq(3)
1071
+ expect(payload[0]).to eq(50)
1072
+ expect(payload[1]).to eq(123)
1073
+ expect(payload[2]).to eq({ test: 1 })
1074
+ end
1075
+
1076
+ end
1077
+
928
1078
  end
929
1079
 
930
1080
  describe WampClient::Message::Register do
@@ -1173,21 +1323,21 @@ describe WampClient::Message do
1173
1323
  describe 'checks optional parameter call_argumentskw' do
1174
1324
 
1175
1325
  it 'creates the message object' do
1176
- params = [123,123,{ test: 1 },['test'],{ test: 1 }]
1326
+ params = [123,123,{ test: 1 },[],{ test: 1 }]
1177
1327
  object = WampClient::Message::Invocation.new(*params)
1178
1328
 
1179
1329
  expect(object.is_a?(WampClient::Message::Invocation)).to eq(true)
1180
1330
  end
1181
1331
 
1182
1332
  it 'parses the message and creates an object' do
1183
- params = [68,123,123,{ test: 1 },['test'],{ test: 1 }]
1333
+ params = [68,123,123,{ test: 1 },[],{ test: 1 }]
1184
1334
  object = WampClient::Message::Invocation.parse(params)
1185
1335
 
1186
1336
  expect(object.is_a?(WampClient::Message::Invocation)).to eq(true)
1187
1337
  end
1188
1338
 
1189
1339
  it 'generates the payload' do
1190
- params = [123,123,{ test: 1 },['test'],{ test: 1 }]
1340
+ params = [123,123,{ test: 1 },[],{ test: 1 }]
1191
1341
  object = WampClient::Message::Invocation.new(*params)
1192
1342
  payload = object.payload
1193
1343
 
@@ -1196,12 +1346,42 @@ describe WampClient::Message do
1196
1346
  expect(payload[1]).to eq(123)
1197
1347
  expect(payload[2]).to eq(123)
1198
1348
  expect(payload[3]).to eq({ test: 1 })
1199
- expect(payload[4]).to eq(['test'])
1349
+ expect(payload[4]).to eq([])
1200
1350
  expect(payload[5]).to eq({ test: 1 })
1201
1351
  end
1202
1352
 
1203
1353
  end
1204
1354
 
1355
+ describe 'checks optional parameters' do
1356
+
1357
+ it 'creates the message object' do
1358
+ params = [123,123,{ test: 1 },[],{}]
1359
+ object = WampClient::Message::Invocation.new(*params)
1360
+
1361
+ expect(object.is_a?(WampClient::Message::Invocation)).to eq(true)
1362
+ end
1363
+
1364
+ it 'parses the message and creates an object' do
1365
+ params = [68,123,123,{ test: 1 },[],{}]
1366
+ object = WampClient::Message::Invocation.parse(params)
1367
+
1368
+ expect(object.is_a?(WampClient::Message::Invocation)).to eq(true)
1369
+ end
1370
+
1371
+ it 'generates the payload' do
1372
+ params = [123,123,{ test: 1 },[],{}]
1373
+ object = WampClient::Message::Invocation.new(*params)
1374
+ payload = object.payload
1375
+
1376
+ expect(payload.count).to eq(4)
1377
+ expect(payload[0]).to eq(68)
1378
+ expect(payload[1]).to eq(123)
1379
+ expect(payload[2]).to eq(123)
1380
+ expect(payload[3]).to eq({ test: 1 })
1381
+ end
1382
+
1383
+ end
1384
+
1205
1385
  end
1206
1386
 
1207
1387
  describe WampClient::Message::Yield do
@@ -1277,21 +1457,21 @@ describe WampClient::Message do
1277
1457
  describe 'checks optional parameter argumentskw' do
1278
1458
 
1279
1459
  it 'creates the message object' do
1280
- params = [123,{ test: 1 },['test'],{ test: 1 }]
1460
+ params = [123,{ test: 1 },[],{ test: 1 }]
1281
1461
  object = WampClient::Message::Yield.new(*params)
1282
1462
 
1283
1463
  expect(object.is_a?(WampClient::Message::Yield)).to eq(true)
1284
1464
  end
1285
1465
 
1286
1466
  it 'parses the message and creates an object' do
1287
- params = [70,123,{ test: 1 },['test'],{ test: 1 }]
1467
+ params = [70,123,{ test: 1 },[],{ test: 1 }]
1288
1468
  object = WampClient::Message::Yield.parse(params)
1289
1469
 
1290
1470
  expect(object.is_a?(WampClient::Message::Yield)).to eq(true)
1291
1471
  end
1292
1472
 
1293
1473
  it 'generates the payload' do
1294
- params = [123,{ test: 1 },['test'],{ test: 1 }]
1474
+ params = [123,{ test: 1 },[],{ test: 1 }]
1295
1475
  object = WampClient::Message::Yield.new(*params)
1296
1476
  payload = object.payload
1297
1477
 
@@ -1299,12 +1479,41 @@ describe WampClient::Message do
1299
1479
  expect(payload[0]).to eq(70)
1300
1480
  expect(payload[1]).to eq(123)
1301
1481
  expect(payload[2]).to eq({ test: 1 })
1302
- expect(payload[3]).to eq(['test'])
1482
+ expect(payload[3]).to eq([])
1303
1483
  expect(payload[4]).to eq({ test: 1 })
1304
1484
  end
1305
1485
 
1306
1486
  end
1307
1487
 
1488
+ describe 'checks optional parameters' do
1489
+
1490
+ it 'creates the message object' do
1491
+ params = [123,{ test: 1 },[],{}]
1492
+ object = WampClient::Message::Yield.new(*params)
1493
+
1494
+ expect(object.is_a?(WampClient::Message::Yield)).to eq(true)
1495
+ end
1496
+
1497
+ it 'parses the message and creates an object' do
1498
+ params = [70,123,{ test: 1 },[],{}]
1499
+ object = WampClient::Message::Yield.parse(params)
1500
+
1501
+ expect(object.is_a?(WampClient::Message::Yield)).to eq(true)
1502
+ end
1503
+
1504
+ it 'generates the payload' do
1505
+ params = [123,{ test: 1 },[],{}]
1506
+ object = WampClient::Message::Yield.new(*params)
1507
+ payload = object.payload
1508
+
1509
+ expect(payload.count).to eq(3)
1510
+ expect(payload[0]).to eq(70)
1511
+ expect(payload[1]).to eq(123)
1512
+ expect(payload[2]).to eq({ test: 1 })
1513
+ end
1514
+
1515
+ end
1516
+
1308
1517
  end
1309
1518
 
1310
1519
  describe WampClient::Message::Challenge do
@@ -1475,4 +1684,4 @@ describe WampClient::Message do
1475
1684
 
1476
1685
  end
1477
1686
 
1478
- end
1687
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wamp_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Chapman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-10 00:00:00.000000000 Z
11
+ date: 2016-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  version: '0'
160
160
  requirements: []
161
161
  rubyforge_project:
162
- rubygems_version: 2.0.14
162
+ rubygems_version: 2.6.6
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Web Application Messaging Protocol Client