punchblock 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +2 -0
  3. data/CHANGELOG.md +6 -0
  4. data/README.markdown +2 -1
  5. data/lib/punchblock/translator/asterisk/call.rb +3 -3
  6. data/lib/punchblock/translator/asterisk/component/mrcp_recog_prompt.rb +15 -9
  7. data/lib/punchblock/translator/asterisk/component/output.rb +8 -1
  8. data/lib/punchblock/translator/input_component.rb +2 -0
  9. data/lib/punchblock/version.rb +1 -1
  10. data/punchblock.gemspec +1 -1
  11. data/spec/punchblock/client/component_registry_spec.rb +3 -3
  12. data/spec/punchblock/client_spec.rb +22 -15
  13. data/spec/punchblock/command/accept_spec.rb +17 -7
  14. data/spec/punchblock/command/answer_spec.rb +19 -9
  15. data/spec/punchblock/command/dial_spec.rb +76 -27
  16. data/spec/punchblock/command/hangup_spec.rb +17 -7
  17. data/spec/punchblock/command/join_spec.rb +78 -24
  18. data/spec/punchblock/command/mute_spec.rb +3 -3
  19. data/spec/punchblock/command/redirect_spec.rb +33 -12
  20. data/spec/punchblock/command/reject_spec.rb +41 -14
  21. data/spec/punchblock/command/unjoin_spec.rb +29 -12
  22. data/spec/punchblock/command/unmute_spec.rb +3 -3
  23. data/spec/punchblock/command_node_spec.rb +43 -20
  24. data/spec/punchblock/component/asterisk/agi/command_spec.rb +52 -12
  25. data/spec/punchblock/component/asterisk/ami/action_spec.rb +69 -21
  26. data/spec/punchblock/component/component_node_spec.rb +12 -12
  27. data/spec/punchblock/component/input_spec.rb +304 -87
  28. data/spec/punchblock/component/output_spec.rb +434 -173
  29. data/spec/punchblock/component/prompt_spec.rb +63 -20
  30. data/spec/punchblock/component/receive_fax_spec.rb +43 -14
  31. data/spec/punchblock/component/record_spec.rb +215 -71
  32. data/spec/punchblock/component/send_fax_spec.rb +54 -15
  33. data/spec/punchblock/connection/asterisk_spec.rb +34 -24
  34. data/spec/punchblock/connection/freeswitch_spec.rb +9 -9
  35. data/spec/punchblock/connection/xmpp_spec.rb +92 -83
  36. data/spec/punchblock/event/answered_spec.rb +14 -4
  37. data/spec/punchblock/event/asterisk/ami/event_spec.rb +34 -12
  38. data/spec/punchblock/event/complete_spec.rb +36 -16
  39. data/spec/punchblock/event/dtmf_spec.rb +9 -3
  40. data/spec/punchblock/event/end_spec.rb +43 -10
  41. data/spec/punchblock/event/input_timers_started_spec.rb +1 -1
  42. data/spec/punchblock/event/joined_spec.rb +29 -7
  43. data/spec/punchblock/event/offer_spec.rb +41 -10
  44. data/spec/punchblock/event/ringing_spec.rb +14 -4
  45. data/spec/punchblock/event/started_speaking_spec.rb +9 -3
  46. data/spec/punchblock/event/stopped_speaking_spec.rb +9 -3
  47. data/spec/punchblock/event/unjoined_spec.rb +24 -6
  48. data/spec/punchblock/protocol_error_spec.rb +16 -13
  49. data/spec/punchblock/ref_spec.rb +90 -26
  50. data/spec/punchblock/translator/asterisk/call_spec.rb +176 -161
  51. data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +18 -18
  52. data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +9 -9
  53. data/spec/punchblock/translator/asterisk/component/composed_prompt_spec.rb +14 -14
  54. data/spec/punchblock/translator/asterisk/component/input_spec.rb +57 -36
  55. data/spec/punchblock/translator/asterisk/component/mrcp_native_prompt_spec.rb +50 -50
  56. data/spec/punchblock/translator/asterisk/component/mrcp_prompt_spec.rb +59 -48
  57. data/spec/punchblock/translator/asterisk/component/output_spec.rb +231 -221
  58. data/spec/punchblock/translator/asterisk/component/record_spec.rb +82 -82
  59. data/spec/punchblock/translator/asterisk/component/stop_by_redirect_spec.rb +10 -10
  60. data/spec/punchblock/translator/asterisk/component_spec.rb +4 -4
  61. data/spec/punchblock/translator/asterisk_spec.rb +89 -82
  62. data/spec/punchblock/translator/freeswitch/call_spec.rb +114 -99
  63. data/spec/punchblock/translator/freeswitch/component/flite_output_spec.rb +19 -19
  64. data/spec/punchblock/translator/freeswitch/component/input_spec.rb +24 -24
  65. data/spec/punchblock/translator/freeswitch/component/output_spec.rb +23 -23
  66. data/spec/punchblock/translator/freeswitch/component/record_spec.rb +78 -78
  67. data/spec/punchblock/translator/freeswitch/component/tts_output_spec.rb +19 -19
  68. data/spec/punchblock/translator/freeswitch/component_spec.rb +8 -8
  69. data/spec/punchblock/translator/freeswitch_spec.rb +66 -59
  70. data/spec/punchblock/uri_list_spec.rb +45 -10
  71. data/spec/punchblock_spec.rb +13 -13
  72. data/spec/spec_helper.rb +18 -11
  73. data/spec/support/mock_connection_with_event_handler.rb +1 -1
  74. metadata +5 -4
@@ -6,19 +6,54 @@ module Punchblock
6
6
  module Component
7
7
  describe Output do
8
8
  it 'registers itself' do
9
- RayoNode.class_from_registration(:output, 'urn:xmpp:rayo:output:1').should be == described_class
9
+ expect(RayoNode.class_from_registration(:output, 'urn:xmpp:rayo:output:1')).to eq(described_class)
10
10
  end
11
11
 
12
12
  describe 'default values' do
13
- its(:interrupt_on) { should be nil }
14
- its(:start_offset) { should be nil }
15
- its(:start_paused) { should be nil }
16
- its(:repeat_interval) { should be nil }
17
- its(:repeat_times) { should be nil }
18
- its(:max_time) { should be nil }
19
- its(:voice) { should be nil }
20
- its(:renderer) { should be nil }
21
- its(:render_documents) { should be == [] }
13
+ describe '#interrupt_on' do
14
+ subject { super().interrupt_on }
15
+ it { should be nil }
16
+ end
17
+
18
+ describe '#start_offset' do
19
+ subject { super().start_offset }
20
+ it { should be nil }
21
+ end
22
+
23
+ describe '#start_paused' do
24
+ subject { super().start_paused }
25
+ it { should be nil }
26
+ end
27
+
28
+ describe '#repeat_interval' do
29
+ subject { super().repeat_interval }
30
+ it { should be nil }
31
+ end
32
+
33
+ describe '#repeat_times' do
34
+ subject { super().repeat_times }
35
+ it { should be nil }
36
+ end
37
+
38
+ describe '#max_time' do
39
+ subject { super().max_time }
40
+ it { should be nil }
41
+ end
42
+
43
+ describe '#voice' do
44
+ subject { super().voice }
45
+ it { should be nil }
46
+ end
47
+
48
+ describe '#renderer' do
49
+ subject { super().renderer }
50
+ it { should be nil }
51
+ end
52
+
53
+ describe '#render_documents' do
54
+ subject { super().render_documents }
55
+ it { should be == [] }
56
+ end
22
57
  end
23
58
 
24
59
  def ssml_doc(mode = :ordinal)
@@ -28,7 +63,7 @@ module Punchblock
28
63
  end
29
64
 
30
65
  describe "when setting options in initializer" do
31
- subject do
66
+ subject(:command) do
32
67
  Output.new :interrupt_on => :voice,
33
68
  :start_offset => 2000,
34
69
  :start_paused => false,
@@ -40,22 +75,60 @@ module Punchblock
40
75
  :render_document => {:value => ssml_doc}
41
76
  end
42
77
 
43
- its(:interrupt_on) { should be == :voice }
44
- its(:start_offset) { should be == 2000 }
45
- its(:start_paused) { should be == false }
46
- its(:repeat_interval) { should be == 2000 }
47
- its(:repeat_times) { should be == 10 }
48
- its(:max_time) { should be == 30000 }
49
- its(:voice) { should be == 'allison' }
50
- its(:renderer) { should be == 'swift' }
51
- its(:render_documents) { should be == [Output::Document.new(:value => ssml_doc)] }
78
+ describe '#interrupt_on' do
79
+ subject { super().interrupt_on }
80
+ it { should be == :voice }
81
+ end
82
+
83
+ describe '#start_offset' do
84
+ subject { super().start_offset }
85
+ it { should be == 2000 }
86
+ end
87
+
88
+ describe '#start_paused' do
89
+ subject { super().start_paused }
90
+ it { should be == false }
91
+ end
92
+
93
+ describe '#repeat_interval' do
94
+ subject { super().repeat_interval }
95
+ it { should be == 2000 }
96
+ end
97
+
98
+ describe '#repeat_times' do
99
+ subject { super().repeat_times }
100
+ it { should be == 10 }
101
+ end
102
+
103
+ describe '#max_time' do
104
+ subject { super().max_time }
105
+ it { should be == 30000 }
106
+ end
107
+
108
+ describe '#voice' do
109
+ subject { super().voice }
110
+ it { should be == 'allison' }
111
+ end
112
+
113
+ describe '#renderer' do
114
+ subject { super().renderer }
115
+ it { should be == 'swift' }
116
+ end
117
+
118
+ describe '#render_documents' do
119
+ subject { super().render_documents }
120
+ it { should be == [Output::Document.new(:value => ssml_doc)] }
121
+ end
52
122
 
53
123
  context "using #ssml=" do
54
124
  subject do
55
125
  Output.new :ssml => ssml_doc
56
126
  end
57
127
 
58
- its(:render_documents) { should be == [Output::Document.new(:value => ssml_doc)] }
128
+ describe '#render_documents' do
129
+ subject { super().render_documents }
130
+ it { should be == [Output::Document.new(:value => ssml_doc)] }
131
+ end
59
132
  end
60
133
 
61
134
  context "with multiple documents" do
@@ -66,10 +139,13 @@ module Punchblock
66
139
  ]
67
140
  end
68
141
 
69
- its(:render_documents) { should be == [
142
+ describe '#render_documents' do
143
+ subject { super().render_documents }
144
+ it { should be == [
70
145
  Output::Document.new(:value => ssml_doc),
71
146
  Output::Document.new(:value => ssml_doc(:cardinal))
72
147
  ]}
148
+ end
73
149
  end
74
150
 
75
151
  context "with a urilist" do
@@ -80,12 +156,15 @@ module Punchblock
80
156
  }
81
157
  end
82
158
 
83
- its(:render_documents) { should be == [Output::Document.new(content_type: 'text/uri-list', value: ['http://example.com/hello.mp3'])] }
159
+ describe '#render_documents' do
160
+ subject { super().render_documents }
161
+ it { should be == [Output::Document.new(content_type: 'text/uri-list', value: ['http://example.com/hello.mp3'])] }
162
+ end
84
163
 
85
164
  describe "exporting to Rayo" do
86
165
  it "should export to XML that can be understood by its parser" do
87
166
  new_instance = RayoNode.from_xml Nokogiri::XML(subject.to_rayo.to_xml, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).root
88
- new_instance.render_documents.should be == [Output::Document.new(content_type: 'text/uri-list', value: ['http://example.com/hello.mp3'])]
167
+ expect(new_instance.render_documents).to eq([Output::Document.new(content_type: 'text/uri-list', value: ['http://example.com/hello.mp3'])])
89
168
  end
90
169
  end
91
170
  end
@@ -93,34 +172,37 @@ module Punchblock
93
172
  context "with a nil document" do
94
173
  it "removes all documents" do
95
174
  subject.render_document = nil
96
- subject.render_documents.should == []
175
+ expect(subject.render_documents).to eq([])
97
176
  end
98
177
  end
99
178
 
100
179
  context "without any documents" do
101
180
  subject { described_class.new }
102
181
 
103
- its(:render_documents) { should == [] }
182
+ describe '#render_documents' do
183
+ subject { super().render_documents }
184
+ it { should == [] }
185
+ end
104
186
  end
105
187
 
106
188
  describe "exporting to Rayo" do
107
189
  it "should export to XML that can be understood by its parser" do
108
190
  new_instance = RayoNode.from_xml Nokogiri::XML(subject.to_rayo.to_xml, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).root
109
- new_instance.should be_instance_of described_class
110
- new_instance.interrupt_on.should be == :voice
111
- new_instance.start_offset.should be == 2000
112
- new_instance.start_paused.should be == false
113
- new_instance.repeat_interval.should be == 2000
114
- new_instance.repeat_times.should be == 10
115
- new_instance.max_time.should be == 30000
116
- new_instance.voice.should be == 'allison'
117
- new_instance.renderer.should be == 'swift'
118
- new_instance.render_documents.should be == [Output::Document.new(:value => ssml_doc)]
191
+ expect(new_instance).to be_instance_of described_class
192
+ expect(new_instance.interrupt_on).to eq(:voice)
193
+ expect(new_instance.start_offset).to eq(2000)
194
+ expect(new_instance.start_paused).to eq(false)
195
+ expect(new_instance.repeat_interval).to eq(2000)
196
+ expect(new_instance.repeat_times).to eq(10)
197
+ expect(new_instance.max_time).to eq(30000)
198
+ expect(new_instance.voice).to eq('allison')
199
+ expect(new_instance.renderer).to eq('swift')
200
+ expect(new_instance.render_documents).to eq([Output::Document.new(:value => ssml_doc)])
119
201
  end
120
202
 
121
203
  it "should wrap the document value in CDATA" do
122
204
  grammar_node = subject.to_rayo.at_xpath('ns:document', ns: described_class.registered_ns)
123
- grammar_node.children.first.should be_a Nokogiri::XML::CDATA
205
+ expect(grammar_node.children.first).to be_a Nokogiri::XML::CDATA
124
206
  end
125
207
 
126
208
  it "should render to a parent node if supplied" do
@@ -128,7 +210,7 @@ module Punchblock
128
210
  parent = Nokogiri::XML::Node.new 'foo', doc
129
211
  doc.root = parent
130
212
  rayo_doc = subject.to_rayo(parent)
131
- rayo_doc.should == parent
213
+ expect(rayo_doc).to eq(parent)
132
214
  end
133
215
 
134
216
  context "with a string SSML document" do
@@ -140,7 +222,7 @@ module Punchblock
140
222
 
141
223
  it "passes the string right through" do
142
224
  content = subject.to_rayo.at_xpath('//ns:output/ns:document/text()', ns: described_class.registered_ns).content
143
- content.should == ssml_string
225
+ expect(content).to eq(ssml_string)
144
226
  end
145
227
  end
146
228
  end
@@ -184,15 +266,50 @@ module Punchblock
184
266
 
185
267
  it { should be_instance_of Output }
186
268
 
187
- its(:interrupt_on) { should be == :voice }
188
- its(:start_offset) { should be == 2000 }
189
- its(:start_paused) { should be == false }
190
- its(:repeat_interval) { should be == 2000 }
191
- its(:repeat_times) { should be == 10 }
192
- its(:max_time) { should be == 30000 }
193
- its(:voice) { should be == 'allison' }
194
- its(:renderer) { should be == 'swift' }
195
- its(:render_documents) { should be == [Output::Document.new(:value => ssml_doc), Output::Document.new(:value => ssml_doc)] }
269
+ describe '#interrupt_on' do
270
+ subject { super().interrupt_on }
271
+ it { should be == :voice }
272
+ end
273
+
274
+ describe '#start_offset' do
275
+ subject { super().start_offset }
276
+ it { should be == 2000 }
277
+ end
278
+
279
+ describe '#start_paused' do
280
+ subject { super().start_paused }
281
+ it { should be == false }
282
+ end
283
+
284
+ describe '#repeat_interval' do
285
+ subject { super().repeat_interval }
286
+ it { should be == 2000 }
287
+ end
288
+
289
+ describe '#repeat_times' do
290
+ subject { super().repeat_times }
291
+ it { should be == 10 }
292
+ end
293
+
294
+ describe '#max_time' do
295
+ subject { super().max_time }
296
+ it { should be == 30000 }
297
+ end
298
+
299
+ describe '#voice' do
300
+ subject { super().voice }
301
+ it { should be == 'allison' }
302
+ end
303
+
304
+ describe '#renderer' do
305
+ subject { super().renderer }
306
+ it { should be == 'swift' }
307
+ end
308
+
309
+ describe '#render_documents' do
310
+ subject { super().render_documents }
311
+ it { should be == [Output::Document.new(:value => ssml_doc), Output::Document.new(:value => ssml_doc)] }
312
+ end
196
313
 
197
314
  context "with a urilist" do
198
315
  let :stanza do
@@ -208,22 +325,35 @@ module Punchblock
208
325
  MESSAGE
209
326
  end
210
327
 
211
- its(:render_documents) { should be == [Output::Document.new(content_type: 'text/uri-list', value: ['http://example.com/hello.mp3', 'http://example.com/goodbye.mp3'])] }
328
+ describe '#render_documents' do
329
+ subject { super().render_documents }
330
+ it { should be == [Output::Document.new(content_type: 'text/uri-list', value: ['http://example.com/hello.mp3', 'http://example.com/goodbye.mp3'])] }
331
+ end
212
332
  end
213
333
  end
214
334
 
215
335
  describe Output::Document do
216
336
  describe "when not passing a content type" do
217
337
  subject { Output::Document.new :value => ssml_doc }
218
- its(:content_type) { should be == 'application/ssml+xml' }
338
+
339
+ describe '#content_type' do
340
+ subject { super().content_type }
341
+ it { should be == 'application/ssml+xml' }
342
+ end
219
343
  end
220
344
 
221
345
  describe 'with an SSML document' do
222
346
  subject { Output::Document.new :value => ssml_doc, :content_type => 'application/ssml+xml' }
223
347
 
224
- its(:content_type) { should be == 'application/ssml+xml' }
348
+ describe '#content_type' do
349
+ subject { super().content_type }
350
+ it { should be == 'application/ssml+xml' }
351
+ end
225
352
 
226
- its(:value) { should be == ssml_doc }
353
+ describe '#value' do
354
+ subject { super().value }
355
+ it { should be == ssml_doc }
356
+ end
227
357
 
228
358
  describe "comparison" do
229
359
  let(:document2) { Output::Document.new :value => ssml_doc }
@@ -237,7 +367,10 @@ module Punchblock
237
367
  describe 'with a urilist' do
238
368
  subject { Output::Document.new content_type: 'text/uri-list', value: Punchblock::URIList.new('http://example.com/hello.mp3', 'http://example.com/goodbye.mp3') }
239
369
 
240
- its(:value) { should be == Punchblock::URIList.new('http://example.com/hello.mp3', 'http://example.com/goodbye.mp3') }
370
+ describe '#value' do
371
+ subject { super().value }
372
+ it { should be == Punchblock::URIList.new('http://example.com/hello.mp3', 'http://example.com/goodbye.mp3') }
373
+ end
241
374
 
242
375
  describe "comparison" do
243
376
  let(:document2) { Output::Document.new content_type: 'text/uri-list', value: Punchblock::URIList.new('http://example.com/hello.mp3', 'http://example.com/goodbye.mp3') }
@@ -257,16 +390,23 @@ module Punchblock
257
390
 
258
391
  subject { Output::Document.new :url => url }
259
392
 
260
- its(:url) { should be == url }
261
- its(:content_type) { should be nil}
393
+ describe '#url' do
394
+ subject { super().url }
395
+ it { should be == url }
396
+ end
397
+
398
+ describe '#content_type' do
399
+ subject { super().content_type }
400
+ it { should be nil}
401
+ end
262
402
 
263
403
  describe "comparison" do
264
404
  it "should be the same with the same url" do
265
- Output::Document.new(:url => url).should be == Output::Document.new(:url => url)
405
+ expect(Output::Document.new(:url => url)).to eq(Output::Document.new(:url => url))
266
406
  end
267
407
 
268
408
  it "should be different with a different url" do
269
- Output::Document.new(:url => url).should_not be == Output::Document.new(:url => 'http://doo.com/dah')
409
+ expect(Output::Document.new(:url => url)).not_to eq(Output::Document.new(:url => 'http://doo.com/dah'))
270
410
  end
271
411
  end
272
412
  end
@@ -285,9 +425,20 @@ module Punchblock
285
425
  describe '#pause_action' do
286
426
  subject { command.pause_action }
287
427
 
288
- its(:to_xml) { should be == '<pause xmlns="urn:xmpp:rayo:output:1"/>' }
289
- its(:component_id) { should be == 'abc123' }
290
- its(:target_call_id) { should be == '123abc' }
428
+ describe '#to_xml' do
429
+ subject { super().to_xml }
430
+ it { should be == '<pause xmlns="urn:xmpp:rayo:output:1"/>' }
431
+ end
432
+
433
+ describe '#component_id' do
434
+ subject { super().component_id }
435
+ it { should be == 'abc123' }
436
+ end
437
+
438
+ describe '#target_call_id' do
439
+ subject { super().target_call_id }
440
+ it { should be == '123abc' }
441
+ end
291
442
  end
292
443
 
293
444
  describe '#pause!' do
@@ -298,39 +449,53 @@ module Punchblock
298
449
  end
299
450
 
300
451
  it "should send its command properly" do
301
- mock_client.should_receive(:execute_command).with(command.pause_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
302
- command.should_receive :paused!
452
+ expect(mock_client).to receive(:execute_command).with(command.pause_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
453
+ expect(command).to receive :paused!
303
454
  command.pause!
304
455
  end
305
456
  end
306
457
 
307
458
  describe "when the command is not executing" do
308
459
  it "should raise an error" do
309
- lambda { command.pause! }.should raise_error(InvalidActionError, "Cannot pause a Output that is not executing")
460
+ expect { command.pause! }.to raise_error(InvalidActionError, "Cannot pause a Output that is not executing")
310
461
  end
311
462
  end
312
463
  end
313
464
 
314
465
  describe "#paused!" do
315
466
  before do
316
- subject.request!
317
- subject.execute!
318
- subject.paused!
467
+ command.request!
468
+ command.execute!
469
+ command.paused!
319
470
  end
320
471
 
321
- its(:state_name) { should be == :paused }
472
+ describe '#state_name' do
473
+ subject { command.state_name }
474
+ it { should be == :paused }
475
+ end
322
476
 
323
477
  it "should raise a StateMachine::InvalidTransition when received a second time" do
324
- lambda { subject.paused! }.should raise_error(StateMachine::InvalidTransition)
478
+ expect { command.paused! }.to raise_error(StateMachine::InvalidTransition)
325
479
  end
326
480
  end
327
481
 
328
482
  describe '#resume_action' do
329
483
  subject { command.resume_action }
330
484
 
331
- its(:to_xml) { should be == '<resume xmlns="urn:xmpp:rayo:output:1"/>' }
332
- its(:component_id) { should be == 'abc123' }
333
- its(:target_call_id) { should be == '123abc' }
485
+ describe '#to_xml' do
486
+ subject { super().to_xml }
487
+ it { should be == '<resume xmlns="urn:xmpp:rayo:output:1"/>' }
488
+ end
489
+
490
+ describe '#component_id' do
491
+ subject { super().component_id }
492
+ it { should be == 'abc123' }
493
+ end
494
+
495
+ describe '#target_call_id' do
496
+ subject { super().target_call_id }
497
+ it { should be == '123abc' }
498
+ end
334
499
  end
335
500
 
336
501
  describe '#resume!' do
@@ -342,40 +507,54 @@ module Punchblock
342
507
  end
343
508
 
344
509
  it "should send its command properly" do
345
- mock_client.should_receive(:execute_command).with(command.resume_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
346
- command.should_receive :resumed!
510
+ expect(mock_client).to receive(:execute_command).with(command.resume_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
511
+ expect(command).to receive :resumed!
347
512
  command.resume!
348
513
  end
349
514
  end
350
515
 
351
516
  describe "when the command is not paused" do
352
517
  it "should raise an error" do
353
- lambda { command.resume! }.should raise_error(InvalidActionError, "Cannot resume a Output that is not paused.")
518
+ expect { command.resume! }.to raise_error(InvalidActionError, "Cannot resume a Output that is not paused.")
354
519
  end
355
520
  end
356
521
  end
357
522
 
358
523
  describe "#resumed!" do
359
524
  before do
360
- subject.request!
361
- subject.execute!
362
- subject.paused!
363
- subject.resumed!
525
+ command.request!
526
+ command.execute!
527
+ command.paused!
528
+ command.resumed!
364
529
  end
365
530
 
366
- its(:state_name) { should be == :executing }
531
+ describe '#state_name' do
532
+ subject { command.state_name }
533
+ it { should be == :executing }
534
+ end
367
535
 
368
536
  it "should raise a StateMachine::InvalidTransition when received a second time" do
369
- lambda { subject.resumed! }.should raise_error(StateMachine::InvalidTransition)
537
+ expect { command.resumed! }.to raise_error(StateMachine::InvalidTransition)
370
538
  end
371
539
  end
372
540
 
373
541
  describe '#stop_action' do
374
542
  subject { command.stop_action }
375
543
 
376
- its(:to_xml) { should be == '<stop xmlns="urn:xmpp:rayo:ext:1"/>' }
377
- its(:component_id) { should be == 'abc123' }
378
- its(:target_call_id) { should be == '123abc' }
544
+ describe '#to_xml' do
545
+ subject { super().to_xml }
546
+ it { should be == '<stop xmlns="urn:xmpp:rayo:ext:1"/>' }
547
+ end
548
+
549
+ describe '#component_id' do
550
+ subject { super().component_id }
551
+ it { should be == 'abc123' }
552
+ end
553
+
554
+ describe '#target_call_id' do
555
+ subject { super().target_call_id }
556
+ it { should be == '123abc' }
557
+ end
379
558
  end
380
559
 
381
560
  describe '#stop!' do
@@ -386,14 +565,14 @@ module Punchblock
386
565
  end
387
566
 
388
567
  it "should send its command properly" do
389
- mock_client.should_receive(:execute_command).with(command.stop_action, :target_call_id => '123abc', :component_id => 'abc123')
568
+ expect(mock_client).to receive(:execute_command).with(command.stop_action, :target_call_id => '123abc', :component_id => 'abc123')
390
569
  command.stop!
391
570
  end
392
571
  end
393
572
 
394
573
  describe "when the command is not executing" do
395
574
  it "should raise an error" do
396
- lambda { command.stop! }.should raise_error(InvalidActionError, "Cannot stop a Output that is new")
575
+ expect { command.stop! }.to raise_error(InvalidActionError, "Cannot stop a Output that is new")
397
576
  end
398
577
  end
399
578
  end # #stop!
@@ -404,9 +583,20 @@ module Punchblock
404
583
  describe '#seek_action' do
405
584
  subject { command.seek_action seek_options }
406
585
 
407
- its(:to_xml) { should be == Nokogiri::XML('<seek xmlns="urn:xmpp:rayo:output:1" direction="forward" amount="1500"/>').root.to_xml }
408
- its(:component_id) { should be == 'abc123' }
409
- its(:target_call_id) { should be == '123abc' }
586
+ describe '#to_xml' do
587
+ subject { super().to_xml }
588
+ it { should be == Nokogiri::XML('<seek xmlns="urn:xmpp:rayo:output:1" direction="forward" amount="1500"/>').root.to_xml }
589
+ end
590
+
591
+ describe '#component_id' do
592
+ subject { super().component_id }
593
+ it { should be == 'abc123' }
594
+ end
595
+
596
+ describe '#target_call_id' do
597
+ subject { super().target_call_id }
598
+ it { should be == '123abc' }
599
+ end
410
600
  end
411
601
 
412
602
  describe '#seek!' do
@@ -418,10 +608,10 @@ module Punchblock
418
608
 
419
609
  it "should send its command properly" do
420
610
  seek_action = command.seek_action seek_options
421
- command.stub(:seek_action).and_return seek_action
422
- mock_client.should_receive(:execute_command).with(seek_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
423
- command.should_receive :seeking!
424
- command.should_receive :stopped_seeking!
611
+ allow(command).to receive(:seek_action).and_return seek_action
612
+ expect(mock_client).to receive(:execute_command).with(seek_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
613
+ expect(command).to receive :seeking!
614
+ expect(command).to receive :stopped_seeking!
425
615
  command.seek! seek_options
426
616
  seek_action.request!
427
617
  seek_action.execute!
@@ -432,37 +622,43 @@ module Punchblock
432
622
  before { command.seeking! }
433
623
 
434
624
  it "should raise an error" do
435
- lambda { command.seek! }.should raise_error(InvalidActionError, "Cannot seek an Output that is already seeking.")
625
+ expect { command.seek! }.to raise_error(InvalidActionError, "Cannot seek an Output that is already seeking.")
436
626
  end
437
627
  end
438
628
  end
439
629
 
440
630
  describe "#seeking!" do
441
631
  before do
442
- subject.request!
443
- subject.execute!
444
- subject.seeking!
632
+ command.request!
633
+ command.execute!
634
+ command.seeking!
445
635
  end
446
636
 
447
- its(:seek_status_name) { should be == :seeking }
637
+ describe '#seek_status_name' do
638
+ subject { command.seek_status_name }
639
+ it { should be == :seeking }
640
+ end
448
641
 
449
642
  it "should raise a StateMachine::InvalidTransition when received a second time" do
450
- lambda { subject.seeking! }.should raise_error(StateMachine::InvalidTransition)
643
+ expect { command.seeking! }.to raise_error(StateMachine::InvalidTransition)
451
644
  end
452
645
  end
453
646
 
454
647
  describe "#stopped_seeking!" do
455
648
  before do
456
- subject.request!
457
- subject.execute!
458
- subject.seeking!
459
- subject.stopped_seeking!
649
+ command.request!
650
+ command.execute!
651
+ command.seeking!
652
+ command.stopped_seeking!
460
653
  end
461
654
 
462
- its(:seek_status_name) { should be == :not_seeking }
655
+ describe '#seek_status_name' do
656
+ subject { super().seek_status_name }
657
+ it { should be == :not_seeking }
658
+ end
463
659
 
464
660
  it "should raise a StateMachine::InvalidTransition when received a second time" do
465
- lambda { subject.stopped_seeking! }.should raise_error(StateMachine::InvalidTransition)
661
+ expect { command.stopped_seeking! }.to raise_error(StateMachine::InvalidTransition)
466
662
  end
467
663
  end
468
664
  end
@@ -471,9 +667,20 @@ module Punchblock
471
667
  describe '#speed_up_action' do
472
668
  subject { command.speed_up_action }
473
669
 
474
- its(:to_xml) { should be == '<speed-up xmlns="urn:xmpp:rayo:output:1"/>' }
475
- its(:component_id) { should be == 'abc123' }
476
- its(:target_call_id) { should be == '123abc' }
670
+ describe '#to_xml' do
671
+ subject { super().to_xml }
672
+ it { should be == '<speed-up xmlns="urn:xmpp:rayo:output:1"/>' }
673
+ end
674
+
675
+ describe '#component_id' do
676
+ subject { super().component_id }
677
+ it { should be == 'abc123' }
678
+ end
679
+
680
+ describe '#target_call_id' do
681
+ subject { super().target_call_id }
682
+ it { should be == '123abc' }
683
+ end
477
684
  end
478
685
 
479
686
  describe '#speed_up!' do
@@ -485,10 +692,10 @@ module Punchblock
485
692
 
486
693
  it "should send its command properly" do
487
694
  speed_up_action = command.speed_up_action
488
- command.stub(:speed_up_action).and_return speed_up_action
489
- mock_client.should_receive(:execute_command).with(speed_up_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
490
- command.should_receive :speeding_up!
491
- command.should_receive :stopped_speeding!
695
+ allow(command).to receive(:speed_up_action).and_return speed_up_action
696
+ expect(mock_client).to receive(:execute_command).with(speed_up_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
697
+ expect(command).to receive :speeding_up!
698
+ expect(command).to receive :stopped_speeding!
492
699
  command.speed_up!
493
700
  speed_up_action.request!
494
701
  speed_up_action.execute!
@@ -499,7 +706,7 @@ module Punchblock
499
706
  before { command.speeding_up! }
500
707
 
501
708
  it "should raise an error" do
502
- lambda { command.speed_up! }.should raise_error(InvalidActionError, "Cannot speed up an Output that is already speeding.")
709
+ expect { command.speed_up! }.to raise_error(InvalidActionError, "Cannot speed up an Output that is already speeding.")
503
710
  end
504
711
  end
505
712
 
@@ -507,31 +714,45 @@ module Punchblock
507
714
  before { command.slowing_down! }
508
715
 
509
716
  it "should raise an error" do
510
- lambda { command.speed_up! }.should raise_error(InvalidActionError, "Cannot speed up an Output that is already speeding.")
717
+ expect { command.speed_up! }.to raise_error(InvalidActionError, "Cannot speed up an Output that is already speeding.")
511
718
  end
512
719
  end
513
720
  end
514
721
 
515
722
  describe "#speeding_up!" do
516
723
  before do
517
- subject.request!
518
- subject.execute!
519
- subject.speeding_up!
724
+ command.request!
725
+ command.execute!
726
+ command.speeding_up!
520
727
  end
521
728
 
522
- its(:speed_status_name) { should be == :speeding_up }
729
+ describe '#speed_status_name' do
730
+ subject { command.speed_status_name }
731
+ it { should be == :speeding_up }
732
+ end
523
733
 
524
734
  it "should raise a StateMachine::InvalidTransition when received a second time" do
525
- lambda { subject.speeding_up! }.should raise_error(StateMachine::InvalidTransition)
735
+ expect { command.speeding_up! }.to raise_error(StateMachine::InvalidTransition)
526
736
  end
527
737
  end
528
738
 
529
739
  describe '#slow_down_action' do
530
740
  subject { command.slow_down_action }
531
741
 
532
- its(:to_xml) { should be == '<speed-down xmlns="urn:xmpp:rayo:output:1"/>' }
533
- its(:component_id) { should be == 'abc123' }
534
- its(:target_call_id) { should be == '123abc' }
742
+ describe '#to_xml' do
743
+ subject { super().to_xml }
744
+ it { should be == '<speed-down xmlns="urn:xmpp:rayo:output:1"/>' }
745
+ end
746
+
747
+ describe '#component_id' do
748
+ subject { super().component_id }
749
+ it { should be == 'abc123' }
750
+ end
751
+
752
+ describe '#target_call_id' do
753
+ subject { super().target_call_id }
754
+ it { should be == '123abc' }
755
+ end
535
756
  end
536
757
 
537
758
  describe '#slow_down!' do
@@ -543,10 +764,10 @@ module Punchblock
543
764
 
544
765
  it "should send its command properly" do
545
766
  slow_down_action = command.slow_down_action
546
- command.stub(:slow_down_action).and_return slow_down_action
547
- mock_client.should_receive(:execute_command).with(slow_down_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
548
- command.should_receive :slowing_down!
549
- command.should_receive :stopped_speeding!
767
+ allow(command).to receive(:slow_down_action).and_return slow_down_action
768
+ expect(mock_client).to receive(:execute_command).with(slow_down_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
769
+ expect(command).to receive :slowing_down!
770
+ expect(command).to receive :stopped_speeding!
550
771
  command.slow_down!
551
772
  slow_down_action.request!
552
773
  slow_down_action.execute!
@@ -557,7 +778,7 @@ module Punchblock
557
778
  before { command.speeding_up! }
558
779
 
559
780
  it "should raise an error" do
560
- lambda { command.slow_down! }.should raise_error(InvalidActionError, "Cannot slow down an Output that is already speeding.")
781
+ expect { command.slow_down! }.to raise_error(InvalidActionError, "Cannot slow down an Output that is already speeding.")
561
782
  end
562
783
  end
563
784
 
@@ -565,37 +786,43 @@ module Punchblock
565
786
  before { command.slowing_down! }
566
787
 
567
788
  it "should raise an error" do
568
- lambda { command.slow_down! }.should raise_error(InvalidActionError, "Cannot slow down an Output that is already speeding.")
789
+ expect { command.slow_down! }.to raise_error(InvalidActionError, "Cannot slow down an Output that is already speeding.")
569
790
  end
570
791
  end
571
792
  end
572
793
 
573
794
  describe "#slowing_down!" do
574
795
  before do
575
- subject.request!
576
- subject.execute!
577
- subject.slowing_down!
796
+ command.request!
797
+ command.execute!
798
+ command.slowing_down!
578
799
  end
579
800
 
580
- its(:speed_status_name) { should be == :slowing_down }
801
+ describe '#speed_status_name' do
802
+ subject { command.speed_status_name }
803
+ it { should be == :slowing_down }
804
+ end
581
805
 
582
806
  it "should raise a StateMachine::InvalidTransition when received a second time" do
583
- lambda { subject.slowing_down! }.should raise_error(StateMachine::InvalidTransition)
807
+ expect { command.slowing_down! }.to raise_error(StateMachine::InvalidTransition)
584
808
  end
585
809
  end
586
810
 
587
811
  describe "#stopped_speeding!" do
588
812
  before do
589
- subject.request!
590
- subject.execute!
591
- subject.speeding_up!
592
- subject.stopped_speeding!
813
+ command.request!
814
+ command.execute!
815
+ command.speeding_up!
816
+ command.stopped_speeding!
593
817
  end
594
818
 
595
- its(:speed_status_name) { should be == :not_speeding }
819
+ describe '#speed_status_name' do
820
+ subject { command.speed_status_name }
821
+ it { should be == :not_speeding }
822
+ end
596
823
 
597
824
  it "should raise a StateMachine::InvalidTransition when received a second time" do
598
- lambda { subject.stopped_speeding! }.should raise_error(StateMachine::InvalidTransition)
825
+ expect { command.stopped_speeding! }.to raise_error(StateMachine::InvalidTransition)
599
826
  end
600
827
  end
601
828
  end
@@ -604,9 +831,20 @@ module Punchblock
604
831
  describe '#volume_up_action' do
605
832
  subject { command.volume_up_action }
606
833
 
607
- its(:to_xml) { should be == '<volume-up xmlns="urn:xmpp:rayo:output:1"/>' }
608
- its(:component_id) { should be == 'abc123' }
609
- its(:target_call_id) { should be == '123abc' }
834
+ describe '#to_xml' do
835
+ subject { super().to_xml }
836
+ it { should be == '<volume-up xmlns="urn:xmpp:rayo:output:1"/>' }
837
+ end
838
+
839
+ describe '#component_id' do
840
+ subject { super().component_id }
841
+ it { should be == 'abc123' }
842
+ end
843
+
844
+ describe '#target_call_id' do
845
+ subject { super().target_call_id }
846
+ it { should be == '123abc' }
847
+ end
610
848
  end
611
849
 
612
850
  describe '#volume_up!' do
@@ -618,10 +856,10 @@ module Punchblock
618
856
 
619
857
  it "should send its command properly" do
620
858
  volume_up_action = command.volume_up_action
621
- command.stub(:volume_up_action).and_return volume_up_action
622
- mock_client.should_receive(:execute_command).with(volume_up_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
623
- command.should_receive :voluming_up!
624
- command.should_receive :stopped_voluming!
859
+ allow(command).to receive(:volume_up_action).and_return volume_up_action
860
+ expect(mock_client).to receive(:execute_command).with(volume_up_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
861
+ expect(command).to receive :voluming_up!
862
+ expect(command).to receive :stopped_voluming!
625
863
  command.volume_up!
626
864
  volume_up_action.request!
627
865
  volume_up_action.execute!
@@ -632,7 +870,7 @@ module Punchblock
632
870
  before { command.voluming_up! }
633
871
 
634
872
  it "should raise an error" do
635
- lambda { command.volume_up! }.should raise_error(InvalidActionError, "Cannot volume up an Output that is already voluming.")
873
+ expect { command.volume_up! }.to raise_error(InvalidActionError, "Cannot volume up an Output that is already voluming.")
636
874
  end
637
875
  end
638
876
 
@@ -640,31 +878,45 @@ module Punchblock
640
878
  before { command.voluming_down! }
641
879
 
642
880
  it "should raise an error" do
643
- lambda { command.volume_up! }.should raise_error(InvalidActionError, "Cannot volume up an Output that is already voluming.")
881
+ expect { command.volume_up! }.to raise_error(InvalidActionError, "Cannot volume up an Output that is already voluming.")
644
882
  end
645
883
  end
646
884
  end
647
885
 
648
886
  describe "#voluming_up!" do
649
887
  before do
650
- subject.request!
651
- subject.execute!
652
- subject.voluming_up!
888
+ command.request!
889
+ command.execute!
890
+ command.voluming_up!
653
891
  end
654
892
 
655
- its(:volume_status_name) { should be == :voluming_up }
893
+ describe '#volume_status_name' do
894
+ subject { command.volume_status_name }
895
+ it { should be == :voluming_up }
896
+ end
656
897
 
657
898
  it "should raise a StateMachine::InvalidTransition when received a second time" do
658
- lambda { subject.voluming_up! }.should raise_error(StateMachine::InvalidTransition)
899
+ expect { command.voluming_up! }.to raise_error(StateMachine::InvalidTransition)
659
900
  end
660
901
  end
661
902
 
662
903
  describe '#volume_down_action' do
663
904
  subject { command.volume_down_action }
664
905
 
665
- its(:to_xml) { should be == '<volume-down xmlns="urn:xmpp:rayo:output:1"/>' }
666
- its(:component_id) { should be == 'abc123' }
667
- its(:target_call_id) { should be == '123abc' }
906
+ describe '#to_xml' do
907
+ subject { super().to_xml }
908
+ it { should be == '<volume-down xmlns="urn:xmpp:rayo:output:1"/>' }
909
+ end
910
+
911
+ describe '#component_id' do
912
+ subject { super().component_id }
913
+ it { should be == 'abc123' }
914
+ end
915
+
916
+ describe '#target_call_id' do
917
+ subject { super().target_call_id }
918
+ it { should be == '123abc' }
919
+ end
668
920
  end
669
921
 
670
922
  describe '#volume_down!' do
@@ -676,10 +928,10 @@ module Punchblock
676
928
 
677
929
  it "should send its command properly" do
678
930
  volume_down_action = command.volume_down_action
679
- command.stub(:volume_down_action).and_return volume_down_action
680
- mock_client.should_receive(:execute_command).with(volume_down_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
681
- command.should_receive :voluming_down!
682
- command.should_receive :stopped_voluming!
931
+ allow(command).to receive(:volume_down_action).and_return volume_down_action
932
+ expect(mock_client).to receive(:execute_command).with(volume_down_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
933
+ expect(command).to receive :voluming_down!
934
+ expect(command).to receive :stopped_voluming!
683
935
  command.volume_down!
684
936
  volume_down_action.request!
685
937
  volume_down_action.execute!
@@ -690,7 +942,7 @@ module Punchblock
690
942
  before { command.voluming_up! }
691
943
 
692
944
  it "should raise an error" do
693
- lambda { command.volume_down! }.should raise_error(InvalidActionError, "Cannot volume down an Output that is already voluming.")
945
+ expect { command.volume_down! }.to raise_error(InvalidActionError, "Cannot volume down an Output that is already voluming.")
694
946
  end
695
947
  end
696
948
 
@@ -698,37 +950,43 @@ module Punchblock
698
950
  before { command.voluming_down! }
699
951
 
700
952
  it "should raise an error" do
701
- lambda { command.volume_down! }.should raise_error(InvalidActionError, "Cannot volume down an Output that is already voluming.")
953
+ expect { command.volume_down! }.to raise_error(InvalidActionError, "Cannot volume down an Output that is already voluming.")
702
954
  end
703
955
  end
704
956
  end
705
957
 
706
958
  describe "#voluming_down!" do
707
959
  before do
708
- subject.request!
709
- subject.execute!
710
- subject.voluming_down!
960
+ command.request!
961
+ command.execute!
962
+ command.voluming_down!
711
963
  end
712
964
 
713
- its(:volume_status_name) { should be == :voluming_down }
965
+ describe '#volume_status_name' do
966
+ subject { command.volume_status_name }
967
+ it { should be == :voluming_down }
968
+ end
714
969
 
715
970
  it "should raise a StateMachine::InvalidTransition when received a second time" do
716
- lambda { subject.voluming_down! }.should raise_error(StateMachine::InvalidTransition)
971
+ expect { command.voluming_down! }.to raise_error(StateMachine::InvalidTransition)
717
972
  end
718
973
  end
719
974
 
720
975
  describe "#stopped_voluming!" do
721
976
  before do
722
- subject.request!
723
- subject.execute!
724
- subject.voluming_up!
725
- subject.stopped_voluming!
977
+ command.request!
978
+ command.execute!
979
+ command.voluming_up!
980
+ command.stopped_voluming!
726
981
  end
727
982
 
728
- its(:volume_status_name) { should be == :not_voluming }
983
+ describe '#volume_status_name' do
984
+ subject { command.volume_status_name }
985
+ it { should be == :not_voluming }
986
+ end
729
987
 
730
988
  it "should raise a StateMachine::InvalidTransition when received a second time" do
731
- lambda { subject.stopped_voluming! }.should raise_error(StateMachine::InvalidTransition)
989
+ expect { command.stopped_voluming! }.to raise_error(StateMachine::InvalidTransition)
732
990
  end
733
991
  end
734
992
  end
@@ -752,7 +1010,10 @@ module Punchblock
752
1010
 
753
1011
  it { should be_instance_of klass }
754
1012
 
755
- its(:name) { should be == element_name }
1013
+ describe '#name' do
1014
+ subject { super().name }
1015
+ it { should be == element_name }
1016
+ end
756
1017
  end
757
1018
  end
758
1019
  end