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,7 +6,7 @@ module Punchblock
6
6
  module Component
7
7
  describe Prompt do
8
8
  it 'registers itself' do
9
- RayoNode.class_from_registration(:prompt, 'urn:xmpp:rayo:prompt:1').should be == described_class
9
+ expect(RayoNode.class_from_registration(:prompt, 'urn:xmpp:rayo:prompt:1')).to eq(described_class)
10
10
  end
11
11
 
12
12
  describe "when setting options in initializer" do
@@ -14,30 +14,51 @@ module Punchblock
14
14
  let(:input) { Input.new :mode => :voice }
15
15
  subject { described_class.new output, input, :barge_in => true }
16
16
 
17
- its(:output) { should be == output }
18
- its(:input) { should be == input }
19
- its(:barge_in) { should be_true }
17
+ describe '#output' do
18
+ subject { super().output }
19
+ it { should be == output }
20
+ end
21
+
22
+ describe '#input' do
23
+ subject { super().input }
24
+ it { should be == input }
25
+ end
26
+
27
+ describe '#barge_in' do
28
+ subject { super().barge_in }
29
+ it { should be_true }
30
+ end
20
31
 
21
32
  context "with barge-in unset" do
22
33
  subject { described_class.new output, input }
23
34
 
24
- its(:barge_in) { should be_nil }
35
+ describe '#barge_in' do
36
+ subject { super().barge_in }
37
+ it { should be_nil }
38
+ end
25
39
  end
26
40
 
27
41
  context "with options for sub-components" do
28
42
  subject { described_class.new({renderer: :foo}, {recognizer: :bar}) }
29
43
 
30
- its(:output) { should be == Output.new(renderer: :foo) }
31
- its(:input) { should be == Input.new(recognizer: :bar) }
44
+ describe '#output' do
45
+ subject { super().output }
46
+ it { should be == Output.new(renderer: :foo) }
47
+ end
48
+
49
+ describe '#input' do
50
+ subject { super().input }
51
+ it { should be == Input.new(recognizer: :bar) }
52
+ end
32
53
  end
33
54
 
34
55
  describe "exporting to Rayo" do
35
56
  it "should export to XML that can be understood by its parser" do
36
57
  new_instance = RayoNode.from_xml subject.to_rayo
37
- new_instance.should be_instance_of described_class
38
- new_instance.output.should be == output
39
- new_instance.input.should be == input
40
- new_instance.barge_in.should be_true
58
+ expect(new_instance).to be_instance_of described_class
59
+ expect(new_instance.output).to eq(output)
60
+ expect(new_instance.input).to eq(input)
61
+ expect(new_instance.barge_in).to be_true
41
62
  end
42
63
 
43
64
  it "should render to a parent node if supplied" do
@@ -45,7 +66,7 @@ module Punchblock
45
66
  parent = Nokogiri::XML::Node.new 'foo', doc
46
67
  doc.root = parent
47
68
  rayo_doc = subject.to_rayo(parent)
48
- rayo_doc.should == parent
69
+ expect(rayo_doc).to eq(parent)
49
70
  end
50
71
  end
51
72
  end
@@ -84,9 +105,20 @@ module Punchblock
84
105
 
85
106
  it { should be_instance_of described_class }
86
107
 
87
- its(:barge_in) { should be_true }
88
- its(:output) { should be == Output.new(:voice => 'allison', :render_document => {:value => ssml}) }
89
- its(:input) { should be == Input.new(:mode => :voice, :grammar => {:value => '[5 DIGITS]', :content_type => 'application/grammar+custom'}) }
108
+ describe '#barge_in' do
109
+ subject { super().barge_in }
110
+ it { should be_true }
111
+ end
112
+
113
+ describe '#output' do
114
+ subject { super().output }
115
+ it { should be == Output.new(:voice => 'allison', :render_document => {:value => ssml}) }
116
+ end
117
+
118
+ describe '#input' do
119
+ subject { super().input }
120
+ it { should be == Input.new(:mode => :voice, :grammar => {:value => '[5 DIGITS]', :content_type => 'application/grammar+custom'}) }
121
+ end
90
122
  end
91
123
 
92
124
  describe "actions" do
@@ -102,9 +134,20 @@ module Punchblock
102
134
  describe '#stop_action' do
103
135
  subject { command.stop_action }
104
136
 
105
- its(:to_xml) { should be == '<stop xmlns="urn:xmpp:rayo:ext:1"/>' }
106
- its(:component_id) { should be == 'abc123' }
107
- its(:target_call_id) { should be == '123abc' }
137
+ describe '#to_xml' do
138
+ subject { super().to_xml }
139
+ it { should be == '<stop xmlns="urn:xmpp:rayo:ext:1"/>' }
140
+ end
141
+
142
+ describe '#component_id' do
143
+ subject { super().component_id }
144
+ it { should be == 'abc123' }
145
+ end
146
+
147
+ describe '#target_call_id' do
148
+ subject { super().target_call_id }
149
+ it { should be == '123abc' }
150
+ end
108
151
  end
109
152
 
110
153
  describe '#stop!' do
@@ -115,14 +158,14 @@ module Punchblock
115
158
  end
116
159
 
117
160
  it "should send its command properly" do
118
- mock_client.should_receive(:execute_command).with(command.stop_action, :target_call_id => '123abc', :component_id => 'abc123')
161
+ expect(mock_client).to receive(:execute_command).with(command.stop_action, :target_call_id => '123abc', :component_id => 'abc123')
119
162
  command.stop!
120
163
  end
121
164
  end
122
165
 
123
166
  describe "when the command is not executing" do
124
167
  it "should raise an error" do
125
- lambda { command.stop! }.should raise_error(InvalidActionError, "Cannot stop a Prompt that is new")
168
+ expect { command.stop! }.to raise_error(InvalidActionError, "Cannot stop a Prompt that is new")
126
169
  end
127
170
  end
128
171
  end
@@ -6,13 +6,13 @@ module Punchblock
6
6
  module Component
7
7
  describe ReceiveFax do
8
8
  it 'registers itself' do
9
- RayoNode.class_from_registration(:receivefax, 'urn:xmpp:rayo:fax:1').should be == described_class
9
+ expect(RayoNode.class_from_registration(:receivefax, 'urn:xmpp:rayo:fax:1')).to eq(described_class)
10
10
  end
11
11
 
12
12
  describe "exporting to Rayo" do
13
13
  it "should export to XML that can be understood by its parser" do
14
14
  new_instance = RayoNode.from_xml subject.to_rayo
15
- new_instance.should be_instance_of described_class
15
+ expect(new_instance).to be_instance_of described_class
16
16
  end
17
17
 
18
18
  it "should render to a parent node if supplied" do
@@ -20,7 +20,7 @@ module Punchblock
20
20
  parent = Nokogiri::XML::Node.new 'foo', doc
21
21
  doc.root = parent
22
22
  rayo_doc = subject.to_rayo(parent)
23
- rayo_doc.should == parent
23
+ expect(rayo_doc).to eq(parent)
24
24
  end
25
25
  end
26
26
 
@@ -49,9 +49,20 @@ module Punchblock
49
49
  describe '#stop_action' do
50
50
  subject { command.stop_action }
51
51
 
52
- its(:to_xml) { should be == '<stop xmlns="urn:xmpp:rayo:ext:1"/>' }
53
- its(:component_id) { should be == 'abc123' }
54
- its(:target_call_id) { should be == '123abc' }
52
+ describe '#to_xml' do
53
+ subject { super().to_xml }
54
+ it { should be == '<stop xmlns="urn:xmpp:rayo:ext:1"/>' }
55
+ end
56
+
57
+ describe '#component_id' do
58
+ subject { super().component_id }
59
+ it { should be == 'abc123' }
60
+ end
61
+
62
+ describe '#target_call_id' do
63
+ subject { super().target_call_id }
64
+ it { should be == '123abc' }
65
+ end
55
66
  end
56
67
 
57
68
  describe '#stop!' do
@@ -62,14 +73,14 @@ module Punchblock
62
73
  end
63
74
 
64
75
  it "should send its command properly" do
65
- mock_client.should_receive(:execute_command).with(command.stop_action, :target_call_id => '123abc', :component_id => 'abc123')
76
+ expect(mock_client).to receive(:execute_command).with(command.stop_action, :target_call_id => '123abc', :component_id => 'abc123')
66
77
  command.stop!
67
78
  end
68
79
  end
69
80
 
70
81
  describe "when the command is not executing" do
71
82
  it "should raise an error" do
72
- lambda { command.stop! }.should raise_error(InvalidActionError, "Cannot stop a ReceiveFax that is new")
83
+ expect { command.stop! }.to raise_error(InvalidActionError, "Cannot stop a ReceiveFax that is new")
73
84
  end
74
85
  end
75
86
  end
@@ -90,7 +101,7 @@ module Punchblock
90
101
  subject(:complete_node) { RayoNode.from_xml(parse_stanza(stanza).root) }
91
102
 
92
103
  it "should understand a finish reason" do
93
- subject.reason.should be_instance_of ReceiveFax::Complete::Finish
104
+ expect(subject.reason).to be_instance_of ReceiveFax::Complete::Finish
94
105
  end
95
106
 
96
107
  describe "should make the fax data available" do
@@ -98,13 +109,31 @@ module Punchblock
98
109
 
99
110
  it { should be_instance_of ReceiveFax::Fax }
100
111
 
101
- its(:url) { should be == 'http://shakespere.lit/faxes/fax1.tiff' }
102
- its(:resolution) { should be == '595x841' }
103
- its(:pages) { should be == 3 }
104
- its(:size) { should be == 12287492817 }
112
+ describe '#url' do
113
+ subject { super().url }
114
+ it { should be == 'http://shakespere.lit/faxes/fax1.tiff' }
115
+ end
116
+
117
+ describe '#resolution' do
118
+ subject { super().resolution }
119
+ it { should be == '595x841' }
120
+ end
121
+
122
+ describe '#pages' do
123
+ subject { super().pages }
124
+ it { should be == 3 }
125
+ end
126
+
127
+ describe '#size' do
128
+ subject { super().size }
129
+ it { should be == 12287492817 }
130
+ end
105
131
  end
106
132
 
107
- its(:fax_metadata) { should == {'fax-transfer-rate' => '10000', 'foo' => 'true'} }
133
+ describe '#fax_metadata' do
134
+ subject { super().fax_metadata }
135
+ it { should == {'fax-transfer-rate' => '10000', 'foo' => 'true'} }
136
+ end
108
137
  end
109
138
  end
110
139
  end
@@ -6,11 +6,11 @@ module Punchblock
6
6
  module Component
7
7
  describe Record do
8
8
  it 'registers itself' do
9
- RayoNode.class_from_registration(:record, 'urn:xmpp:rayo:record:1').should be == described_class
9
+ expect(RayoNode.class_from_registration(:record, 'urn:xmpp:rayo:record:1')).to eq(described_class)
10
10
  end
11
11
 
12
12
  describe "when setting options in initializer" do
13
- subject do
13
+ subject(:command) do
14
14
  Record.new :format => 'WAV',
15
15
  :start_beep => true,
16
16
  :stop_beep => false,
@@ -22,29 +22,64 @@ module Punchblock
22
22
  :mix => true
23
23
  end
24
24
 
25
- its(:format) { should be == 'WAV' }
26
- its(:start_beep) { should be == true }
27
- its(:stop_beep) { should be == false }
28
- its(:start_paused) { should be == false }
29
- its(:max_duration) { should be == 500000 }
30
- its(:initial_timeout) { should be == 10000 }
31
- its(:final_timeout) { should be == 30000 }
32
- its(:direction) { should be == :duplex }
33
- its(:mix) { should be == true }
25
+ describe '#format' do
26
+ subject { super().format }
27
+ it { should be == 'WAV' }
28
+ end
29
+
30
+ describe '#start_beep' do
31
+ subject { super().start_beep }
32
+ it { should be == true }
33
+ end
34
+
35
+ describe '#stop_beep' do
36
+ subject { super().stop_beep }
37
+ it { should be == false }
38
+ end
39
+
40
+ describe '#start_paused' do
41
+ subject { super().start_paused }
42
+ it { should be == false }
43
+ end
44
+
45
+ describe '#max_duration' do
46
+ subject { super().max_duration }
47
+ it { should be == 500000 }
48
+ end
49
+
50
+ describe '#initial_timeout' do
51
+ subject { super().initial_timeout }
52
+ it { should be == 10000 }
53
+ end
54
+
55
+ describe '#final_timeout' do
56
+ subject { super().final_timeout }
57
+ it { should be == 30000 }
58
+ end
59
+
60
+ describe '#direction' do
61
+ subject { super().direction }
62
+ it { should be == :duplex }
63
+ end
64
+
65
+ describe '#mix' do
66
+ subject { super().mix }
67
+ it { should be == true }
68
+ end
34
69
 
35
70
  describe "exporting to Rayo" do
36
71
  it "should export to XML that can be understood by its parser" do
37
72
  new_instance = RayoNode.from_xml subject.to_rayo
38
- new_instance.should be_instance_of described_class
39
- new_instance.format.should be == 'WAV'
40
- new_instance.start_beep.should be == true
41
- new_instance.stop_beep.should be == false
42
- new_instance.start_paused.should be == false
43
- new_instance.max_duration.should be == 500000
44
- new_instance.initial_timeout.should be == 10000
45
- new_instance.final_timeout.should be == 30000
46
- new_instance.direction.should be == :duplex
47
- new_instance.mix.should be == true
73
+ expect(new_instance).to be_instance_of described_class
74
+ expect(new_instance.format).to eq('WAV')
75
+ expect(new_instance.start_beep).to eq(true)
76
+ expect(new_instance.stop_beep).to eq(false)
77
+ expect(new_instance.start_paused).to eq(false)
78
+ expect(new_instance.max_duration).to eq(500000)
79
+ expect(new_instance.initial_timeout).to eq(10000)
80
+ expect(new_instance.final_timeout).to eq(30000)
81
+ expect(new_instance.direction).to eq(:duplex)
82
+ expect(new_instance.mix).to eq(true)
48
83
  end
49
84
 
50
85
  it "should render to a parent node if supplied" do
@@ -52,7 +87,7 @@ module Punchblock
52
87
  parent = Nokogiri::XML::Node.new 'foo', doc
53
88
  doc.root = parent
54
89
  rayo_doc = subject.to_rayo(parent)
55
- rayo_doc.should == parent
90
+ expect(rayo_doc).to eq(parent)
56
91
  end
57
92
  end
58
93
  end
@@ -77,15 +112,50 @@ module Punchblock
77
112
 
78
113
  it { should be_instance_of Record }
79
114
 
80
- its(:format) { should be == 'WAV' }
81
- its(:start_beep) { should be == true }
82
- its(:stop_beep) { should be == false }
83
- its(:start_paused) { should be == false }
84
- its(:max_duration) { should be == 500000 }
85
- its(:initial_timeout) { should be == 10000 }
86
- its(:final_timeout) { should be == 30000 }
87
- its(:direction) { should be == :duplex }
88
- its(:mix) { should be == true }
115
+ describe '#format' do
116
+ subject { super().format }
117
+ it { should be == 'WAV' }
118
+ end
119
+
120
+ describe '#start_beep' do
121
+ subject { super().start_beep }
122
+ it { should be == true }
123
+ end
124
+
125
+ describe '#stop_beep' do
126
+ subject { super().stop_beep }
127
+ it { should be == false }
128
+ end
129
+
130
+ describe '#start_paused' do
131
+ subject { super().start_paused }
132
+ it { should be == false }
133
+ end
134
+
135
+ describe '#max_duration' do
136
+ subject { super().max_duration }
137
+ it { should be == 500000 }
138
+ end
139
+
140
+ describe '#initial_timeout' do
141
+ subject { super().initial_timeout }
142
+ it { should be == 10000 }
143
+ end
144
+
145
+ describe '#final_timeout' do
146
+ subject { super().final_timeout }
147
+ it { should be == 30000 }
148
+ end
149
+
150
+ describe '#direction' do
151
+ subject { super().direction }
152
+ it { should be == :duplex }
153
+ end
154
+
155
+ describe '#mix' do
156
+ subject { super().mix }
157
+ it { should be == true }
158
+ end
89
159
  end
90
160
 
91
161
  describe "with a direction" do
@@ -93,14 +163,20 @@ module Punchblock
93
163
  describe direction do
94
164
  subject { described_class.new :direction => direction }
95
165
 
96
- its(:direction) { should be == direction }
166
+ describe '#direction' do
167
+ subject { super().direction }
168
+ it { should be == direction }
169
+ end
97
170
  end
98
171
  end
99
172
 
100
173
  describe "no direction" do
101
174
  subject { Record.new }
102
175
 
103
- its(:direction) { should be_nil }
176
+ describe '#direction' do
177
+ subject { super().direction }
178
+ it { should be_nil }
179
+ end
104
180
  end
105
181
 
106
182
  describe "blahblahblah" do
@@ -123,9 +199,20 @@ module Punchblock
123
199
  describe '#pause_action' do
124
200
  subject { command.pause_action }
125
201
 
126
- its(:to_xml) { should be == '<pause xmlns="urn:xmpp:rayo:record:1"/>' }
127
- its(:component_id) { should be == 'abc123' }
128
- its(:target_call_id) { should be == '123abc' }
202
+ describe '#to_xml' do
203
+ subject { super().to_xml }
204
+ it { should be == '<pause xmlns="urn:xmpp:rayo:record:1"/>' }
205
+ end
206
+
207
+ describe '#component_id' do
208
+ subject { super().component_id }
209
+ it { should be == 'abc123' }
210
+ end
211
+
212
+ describe '#target_call_id' do
213
+ subject { super().target_call_id }
214
+ it { should be == '123abc' }
215
+ end
129
216
  end
130
217
 
131
218
  describe '#pause!' do
@@ -136,39 +223,53 @@ module Punchblock
136
223
  end
137
224
 
138
225
  it "should send its command properly" do
139
- mock_client.should_receive(:execute_command).with(command.pause_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
140
- command.should_receive :paused!
226
+ expect(mock_client).to receive(:execute_command).with(command.pause_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
227
+ expect(command).to receive :paused!
141
228
  command.pause!
142
229
  end
143
230
  end
144
231
 
145
232
  describe "when the command is not executing" do
146
233
  it "should raise an error" do
147
- lambda { command.pause! }.should raise_error(InvalidActionError, "Cannot pause a Record that is not executing")
234
+ expect { command.pause! }.to raise_error(InvalidActionError, "Cannot pause a Record that is not executing")
148
235
  end
149
236
  end
150
237
  end
151
238
 
152
239
  describe "#paused!" do
153
240
  before do
154
- subject.request!
155
- subject.execute!
156
- subject.paused!
241
+ command.request!
242
+ command.execute!
243
+ command.paused!
157
244
  end
158
245
 
159
- its(:state_name) { should be == :paused }
246
+ describe '#state_name' do
247
+ subject { command.state_name }
248
+ it { should be == :paused }
249
+ end
160
250
 
161
251
  it "should raise a StateMachine::InvalidTransition when received a second time" do
162
- lambda { subject.paused! }.should raise_error(StateMachine::InvalidTransition)
252
+ expect { subject.paused! }.to raise_error(StateMachine::InvalidTransition)
163
253
  end
164
254
  end
165
255
 
166
256
  describe '#resume_action' do
167
257
  subject { command.resume_action }
168
258
 
169
- its(:to_xml) { should be == '<resume xmlns="urn:xmpp:rayo:record:1"/>' }
170
- its(:component_id) { should be == 'abc123' }
171
- its(:target_call_id) { should be == '123abc' }
259
+ describe '#to_xml' do
260
+ subject { super().to_xml }
261
+ it { should be == '<resume xmlns="urn:xmpp:rayo:record:1"/>' }
262
+ end
263
+
264
+ describe '#component_id' do
265
+ subject { super().component_id }
266
+ it { should be == 'abc123' }
267
+ end
268
+
269
+ describe '#target_call_id' do
270
+ subject { super().target_call_id }
271
+ it { should be == '123abc' }
272
+ end
172
273
  end
173
274
 
174
275
  describe '#resume!' do
@@ -180,31 +281,34 @@ module Punchblock
180
281
  end
181
282
 
182
283
  it "should send its command properly" do
183
- mock_client.should_receive(:execute_command).with(command.resume_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
184
- command.should_receive :resumed!
284
+ expect(mock_client).to receive(:execute_command).with(command.resume_action, :target_call_id => '123abc', :component_id => 'abc123').and_return true
285
+ expect(command).to receive :resumed!
185
286
  command.resume!
186
287
  end
187
288
  end
188
289
 
189
290
  describe "when the command is not paused" do
190
291
  it "should raise an error" do
191
- lambda { command.resume! }.should raise_error(InvalidActionError, "Cannot resume a Record that is not paused.")
292
+ expect { command.resume! }.to raise_error(InvalidActionError, "Cannot resume a Record that is not paused.")
192
293
  end
193
294
  end
194
295
  end
195
296
 
196
297
  describe "#resumed!" do
197
298
  before do
198
- subject.request!
199
- subject.execute!
200
- subject.paused!
201
- subject.resumed!
299
+ command.request!
300
+ command.execute!
301
+ command.paused!
302
+ command.resumed!
202
303
  end
203
304
 
204
- its(:state_name) { should be == :executing }
305
+ describe '#state_name' do
306
+ subject { command.state_name }
307
+ it { should be == :executing }
308
+ end
205
309
 
206
310
  it "should raise a StateMachine::InvalidTransition when received a second time" do
207
- lambda { subject.resumed! }.should raise_error(StateMachine::InvalidTransition)
311
+ expect { subject.resumed! }.to raise_error(StateMachine::InvalidTransition)
208
312
  end
209
313
  end
210
314
 
@@ -227,13 +331,13 @@ module Punchblock
227
331
 
228
332
  describe "#recording" do
229
333
  it "should be a Punchblock::Component::Record::Recording" do
230
- subject.recording.should be_a Punchblock::Component::Record::Recording
334
+ expect(subject.recording).to be_a Punchblock::Component::Record::Recording
231
335
  end
232
336
  end
233
337
 
234
338
  describe "#recording_uri" do
235
339
  it "should be the recording URI set earlier" do
236
- subject.recording_uri.should be == "file:/tmp/rayo7451601434771683422.mp3"
340
+ expect(subject.recording_uri).to eq("file:/tmp/rayo7451601434771683422.mp3")
237
341
  end
238
342
  end
239
343
  end
@@ -241,9 +345,20 @@ module Punchblock
241
345
  describe '#stop_action' do
242
346
  subject { command.stop_action }
243
347
 
244
- its(:to_xml) { should be == '<stop xmlns="urn:xmpp:rayo:ext:1"/>' }
245
- its(:component_id) { should be == 'abc123' }
246
- its(:target_call_id) { should be == '123abc' }
348
+ describe '#to_xml' do
349
+ subject { super().to_xml }
350
+ it { should be == '<stop xmlns="urn:xmpp:rayo:ext:1"/>' }
351
+ end
352
+
353
+ describe '#component_id' do
354
+ subject { super().component_id }
355
+ it { should be == 'abc123' }
356
+ end
357
+
358
+ describe '#target_call_id' do
359
+ subject { super().target_call_id }
360
+ it { should be == '123abc' }
361
+ end
247
362
  end
248
363
 
249
364
  describe '#stop!' do
@@ -254,14 +369,14 @@ module Punchblock
254
369
  end
255
370
 
256
371
  it "should send its command properly" do
257
- mock_client.should_receive(:execute_command).with(command.stop_action, :target_call_id => '123abc', :component_id => 'abc123')
372
+ expect(mock_client).to receive(:execute_command).with(command.stop_action, :target_call_id => '123abc', :component_id => 'abc123')
258
373
  command.stop!
259
374
  end
260
375
  end
261
376
 
262
377
  describe "when the command is not executing" do
263
378
  it "should raise an error" do
264
- lambda { command.stop! }.should raise_error(InvalidActionError, "Cannot stop a Record that is new")
379
+ expect { command.stop! }.to raise_error(InvalidActionError, "Cannot stop a Record that is new")
265
380
  end
266
381
  end
267
382
  end
@@ -287,16 +402,31 @@ module Punchblock
287
402
 
288
403
  it { should be_instance_of klass }
289
404
 
290
- its(:name) { should be == element_name }
405
+ describe '#name' do
406
+ subject { super().name }
407
+ it { should be == element_name }
408
+ end
291
409
  end
292
410
 
293
411
  describe "#recording" do
294
412
  subject { RayoNode.from_xml(parse_stanza(stanza).root).recording }
295
413
 
296
414
  it { should be_instance_of Record::Recording }
297
- its(:uri) { should be == "file:/tmp/rayo7451601434771683422.mp3" }
298
- its(:duration) { should be == 34000 }
299
- its(:size) { should be == 23450 }
415
+
416
+ describe '#uri' do
417
+ subject { super().uri }
418
+ it { should be == "file:/tmp/rayo7451601434771683422.mp3" }
419
+ end
420
+
421
+ describe '#duration' do
422
+ subject { super().duration }
423
+ it { should be == 34000 }
424
+ end
425
+
426
+ describe '#size' do
427
+ subject { super().size }
428
+ it { should be == 23450 }
429
+ end
300
430
  end
301
431
  end
302
432
  end
@@ -316,14 +446,21 @@ module Punchblock
316
446
 
317
447
  it { should be_instance_of Event::Complete::Stop }
318
448
 
319
- its(:name) { should be == :stop }
449
+ describe '#name' do
450
+ subject { super().name }
451
+ it { should be == :stop }
452
+ end
320
453
  end
321
454
 
322
455
  describe "#recording" do
323
456
  subject { RayoNode.from_xml(parse_stanza(stanza).root).recording }
324
457
 
325
458
  it { should be_instance_of Record::Recording }
326
- its(:uri) { should be == "file:/tmp/rayo7451601434771683422.mp3" }
459
+
460
+ describe '#uri' do
461
+ subject { super().uri }
462
+ it { should be == "file:/tmp/rayo7451601434771683422.mp3" }
463
+ end
327
464
  end
328
465
  end
329
466
 
@@ -342,14 +479,21 @@ module Punchblock
342
479
 
343
480
  it { should be_instance_of Event::Complete::Hangup }
344
481
 
345
- its(:name) { should be == :hangup }
482
+ describe '#name' do
483
+ subject { super().name }
484
+ it { should be == :hangup }
485
+ end
346
486
  end
347
487
 
348
488
  describe "#recording" do
349
489
  subject { RayoNode.from_xml(parse_stanza(stanza).root).recording }
350
490
 
351
491
  it { should be_instance_of Record::Recording }
352
- its(:uri) { should be == "file:/tmp/rayo7451601434771683422.mp3" }
492
+
493
+ describe '#uri' do
494
+ subject { super().uri }
495
+ it { should be == "file:/tmp/rayo7451601434771683422.mp3" }
496
+ end
353
497
  end
354
498
  end
355
499
  end