punchblock 0.9.2 → 0.10.0
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.
- data/.gitignore +1 -0
- data/CHANGELOG.md +34 -21
- data/Rakefile +20 -0
- data/lib/punchblock/client/component_registry.rb +2 -0
- data/lib/punchblock/client.rb +2 -2
- data/lib/punchblock/command/accept.rb +2 -0
- data/lib/punchblock/command/answer.rb +2 -0
- data/lib/punchblock/command/dial.rb +2 -0
- data/lib/punchblock/command/hangup.rb +2 -0
- data/lib/punchblock/command/join.rb +2 -0
- data/lib/punchblock/command/mute.rb +2 -0
- data/lib/punchblock/command/redirect.rb +2 -0
- data/lib/punchblock/command/reject.rb +3 -1
- data/lib/punchblock/command/unjoin.rb +2 -0
- data/lib/punchblock/command/unmute.rb +2 -0
- data/lib/punchblock/command.rb +2 -0
- data/lib/punchblock/command_node.rb +2 -0
- data/lib/punchblock/component/asterisk/agi/command.rb +4 -2
- data/lib/punchblock/component/asterisk/agi.rb +2 -0
- data/lib/punchblock/component/asterisk/ami/action.rb +4 -2
- data/lib/punchblock/component/asterisk/ami.rb +2 -0
- data/lib/punchblock/component/asterisk.rb +2 -0
- data/lib/punchblock/component/component_node.rb +2 -0
- data/lib/punchblock/component/input.rb +2 -0
- data/lib/punchblock/component/output.rb +2 -0
- data/lib/punchblock/component/record.rb +2 -0
- data/lib/punchblock/component/stop.rb +2 -0
- data/lib/punchblock/component.rb +2 -0
- data/lib/punchblock/connection/asterisk.rb +4 -1
- data/lib/punchblock/connection/connected.rb +2 -0
- data/lib/punchblock/connection/generic_connection.rb +5 -0
- data/lib/punchblock/connection/xmpp.rb +5 -6
- data/lib/punchblock/connection.rb +2 -0
- data/lib/punchblock/core_ext/blather/stanza/presence.rb +2 -0
- data/lib/punchblock/core_ext/blather/stanza.rb +2 -0
- data/lib/punchblock/core_ext/ruby.rb +1 -12
- data/lib/punchblock/disconnected_error.rb +2 -0
- data/lib/punchblock/event/answered.rb +2 -0
- data/lib/punchblock/event/asterisk/ami/event.rb +3 -1
- data/lib/punchblock/event/asterisk/ami.rb +2 -0
- data/lib/punchblock/event/asterisk.rb +2 -0
- data/lib/punchblock/event/complete.rb +3 -1
- data/lib/punchblock/event/dtmf.rb +2 -0
- data/lib/punchblock/event/end.rb +2 -0
- data/lib/punchblock/event/joined.rb +2 -0
- data/lib/punchblock/event/offer.rb +6 -0
- data/lib/punchblock/event/ringing.rb +2 -0
- data/lib/punchblock/event/unjoined.rb +2 -0
- data/lib/punchblock/event.rb +2 -0
- data/lib/punchblock/has_headers.rb +3 -1
- data/lib/punchblock/header.rb +2 -0
- data/lib/punchblock/key_value_pair_node.rb +2 -0
- data/lib/punchblock/media_container.rb +2 -0
- data/lib/punchblock/media_node.rb +2 -0
- data/lib/punchblock/protocol_error.rb +2 -0
- data/lib/punchblock/rayo_node.rb +4 -3
- data/lib/punchblock/ref.rb +2 -0
- data/lib/punchblock/translator/asterisk/call.rb +80 -26
- data/lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb +3 -1
- data/lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb +3 -1
- data/lib/punchblock/translator/asterisk/component/asterisk.rb +2 -0
- data/lib/punchblock/translator/asterisk/component/input.rb +4 -2
- data/lib/punchblock/translator/asterisk/component/output.rb +21 -3
- data/lib/punchblock/translator/asterisk/component.rb +2 -0
- data/lib/punchblock/translator/asterisk.rb +50 -20
- data/lib/punchblock/translator.rb +2 -0
- data/lib/punchblock/version.rb +3 -1
- data/lib/punchblock.rb +2 -0
- data/punchblock.gemspec +2 -2
- data/spec/capture_warnings.rb +32 -0
- data/spec/punchblock/client/component_registry_spec.rb +2 -0
- data/spec/punchblock/client_spec.rb +3 -1
- data/spec/punchblock/command/accept_spec.rb +3 -1
- data/spec/punchblock/command/answer_spec.rb +3 -1
- data/spec/punchblock/command/dial_spec.rb +12 -10
- data/spec/punchblock/command/hangup_spec.rb +3 -1
- data/spec/punchblock/command/join_spec.rb +11 -9
- data/spec/punchblock/command/mute_spec.rb +3 -1
- data/spec/punchblock/command/redirect_spec.rb +5 -3
- data/spec/punchblock/command/reject_spec.rb +7 -5
- data/spec/punchblock/command/unjoin_spec.rb +7 -5
- data/spec/punchblock/command/unmute_spec.rb +3 -1
- data/spec/punchblock/command_node_spec.rb +9 -7
- data/spec/punchblock/component/asterisk/agi/command_spec.rb +21 -19
- data/spec/punchblock/component/asterisk/ami/action_spec.rb +19 -17
- data/spec/punchblock/component/component_node_spec.rb +5 -3
- data/spec/punchblock/component/input_spec.rb +51 -49
- data/spec/punchblock/component/output_spec.rb +60 -58
- data/spec/punchblock/component/record_spec.rb +36 -34
- data/spec/punchblock/connection/asterisk_spec.rb +9 -4
- data/spec/punchblock/connection/xmpp_spec.rb +40 -39
- data/spec/punchblock/event/answered_spec.rb +4 -2
- data/spec/punchblock/event/asterisk/ami/event_spec.rb +9 -7
- data/spec/punchblock/event/complete_spec.rb +12 -10
- data/spec/punchblock/event/dtmf_spec.rb +6 -4
- data/spec/punchblock/event/end_spec.rb +6 -4
- data/spec/punchblock/event/joined_spec.rb +8 -6
- data/spec/punchblock/event/offer_spec.rb +7 -5
- data/spec/punchblock/event/ringing_spec.rb +4 -2
- data/spec/punchblock/event/unjoined_spec.rb +8 -6
- data/spec/punchblock/header_spec.rb +13 -11
- data/spec/punchblock/protocol_error_spec.rb +8 -6
- data/spec/punchblock/ref_spec.rb +5 -3
- data/spec/punchblock/translator/asterisk/call_spec.rb +261 -14
- data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +13 -11
- data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +4 -2
- data/spec/punchblock/translator/asterisk/component/input_spec.rb +10 -8
- data/spec/punchblock/translator/asterisk/component/output_spec.rb +111 -20
- data/spec/punchblock/translator/asterisk/component_spec.rb +3 -1
- data/spec/punchblock/translator/asterisk_spec.rb +107 -10
- data/spec/spec_helper.rb +23 -17
- data/spec/support/mock_connection_with_event_handler.rb +2 -0
- metadata +43 -41
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
module Punchblock
|
|
4
6
|
module Component
|
|
5
7
|
describe Input do
|
|
6
8
|
it 'registers itself' do
|
|
7
|
-
RayoNode.class_from_registration(:input, 'urn:xmpp:rayo:input:1').should == Input
|
|
9
|
+
RayoNode.class_from_registration(:input, 'urn:xmpp:rayo:input:1').should be == Input
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
describe "when setting options in initializer" do
|
|
@@ -24,19 +26,19 @@ module Punchblock
|
|
|
24
26
|
:min_confidence => 0.5
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
its(:grammar) { should == Input::Grammar.new(:value => '[5 DIGITS]', :content_type => 'application/grammar+custom') }
|
|
28
|
-
its(:mode) { should == :speech }
|
|
29
|
-
its(:terminator) { should == '#' }
|
|
30
|
-
its(:max_digits) { should == 10 }
|
|
31
|
-
its(:max_silence) { should == 1000 }
|
|
32
|
-
its(:recognizer) { should == 'en-US' }
|
|
33
|
-
its(:initial_timeout) { should == 2000 }
|
|
34
|
-
its(:inter_digit_timeout) { should == 2000 }
|
|
35
|
-
its(:term_timeout) { should == 2000 }
|
|
36
|
-
its(:complete_timeout) { should == 2000 }
|
|
37
|
-
its(:incomplete_timeout) { should == 2000 }
|
|
38
|
-
its(:sensitivity) { should == 0.5 }
|
|
39
|
-
its(:min_confidence) { should == 0.5 }
|
|
29
|
+
its(:grammar) { should be == Input::Grammar.new(:value => '[5 DIGITS]', :content_type => 'application/grammar+custom') }
|
|
30
|
+
its(:mode) { should be == :speech }
|
|
31
|
+
its(:terminator) { should be == '#' }
|
|
32
|
+
its(:max_digits) { should be == 10 }
|
|
33
|
+
its(:max_silence) { should be == 1000 }
|
|
34
|
+
its(:recognizer) { should be == 'en-US' }
|
|
35
|
+
its(:initial_timeout) { should be == 2000 }
|
|
36
|
+
its(:inter_digit_timeout) { should be == 2000 }
|
|
37
|
+
its(:term_timeout) { should be == 2000 }
|
|
38
|
+
its(:complete_timeout) { should be == 2000 }
|
|
39
|
+
its(:incomplete_timeout) { should be == 2000 }
|
|
40
|
+
its(:sensitivity) { should be == 0.5 }
|
|
41
|
+
its(:min_confidence) { should be == 0.5 }
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
describe "from a stanza" do
|
|
@@ -66,19 +68,19 @@ module Punchblock
|
|
|
66
68
|
|
|
67
69
|
it { should be_instance_of Input }
|
|
68
70
|
|
|
69
|
-
its(:grammar) { should == Input::Grammar.new(:value => '[5 DIGITS]', :content_type => 'application/grammar+custom') }
|
|
70
|
-
its(:mode) { should == :speech }
|
|
71
|
-
its(:terminator) { should == '#' }
|
|
72
|
-
its(:max_digits) { should == 10 }
|
|
73
|
-
its(:max_silence) { should == 1000 }
|
|
74
|
-
its(:recognizer) { should == 'en-US' }
|
|
75
|
-
its(:initial_timeout) { should == 2000 }
|
|
76
|
-
its(:inter_digit_timeout) { should == 2000 }
|
|
77
|
-
its(:term_timeout) { should == 2000 }
|
|
78
|
-
its(:complete_timeout) { should == 2000 }
|
|
79
|
-
its(:incomplete_timeout) { should == 2000 }
|
|
80
|
-
its(:sensitivity) { should == 0.5 }
|
|
81
|
-
its(:min_confidence) { should == 0.5 }
|
|
71
|
+
its(:grammar) { should be == Input::Grammar.new(:value => '[5 DIGITS]', :content_type => 'application/grammar+custom') }
|
|
72
|
+
its(:mode) { should be == :speech }
|
|
73
|
+
its(:terminator) { should be == '#' }
|
|
74
|
+
its(:max_digits) { should be == 10 }
|
|
75
|
+
its(:max_silence) { should be == 1000 }
|
|
76
|
+
its(:recognizer) { should be == 'en-US' }
|
|
77
|
+
its(:initial_timeout) { should be == 2000 }
|
|
78
|
+
its(:inter_digit_timeout) { should be == 2000 }
|
|
79
|
+
its(:term_timeout) { should be == 2000 }
|
|
80
|
+
its(:complete_timeout) { should be == 2000 }
|
|
81
|
+
its(:incomplete_timeout) { should be == 2000 }
|
|
82
|
+
its(:sensitivity) { should be == 0.5 }
|
|
83
|
+
its(:min_confidence) { should be == 0.5 }
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
def grxml_doc(mode = :dtmf)
|
|
@@ -94,7 +96,7 @@ module Punchblock
|
|
|
94
96
|
describe Input::Grammar do
|
|
95
97
|
describe "when not passing a content type" do
|
|
96
98
|
subject { Input::Grammar.new :value => grxml_doc }
|
|
97
|
-
its(:content_type) { should == 'application/grammar+grxml' }
|
|
99
|
+
its(:content_type) { should be == 'application/grammar+grxml' }
|
|
98
100
|
end
|
|
99
101
|
|
|
100
102
|
describe 'with a simple grammar' do
|
|
@@ -103,31 +105,31 @@ module Punchblock
|
|
|
103
105
|
let(:expected_message) { "<![CDATA[ [5 DIGITS] ]]>" }
|
|
104
106
|
|
|
105
107
|
it "should wrap grammar in CDATA" do
|
|
106
|
-
subject.child.to_xml.should == expected_message.strip
|
|
108
|
+
subject.child.to_xml.should be == expected_message.strip
|
|
107
109
|
end
|
|
108
110
|
end
|
|
109
111
|
|
|
110
112
|
describe 'with a GRXML grammar' do
|
|
111
113
|
subject { Input::Grammar.new :value => grxml_doc, :content_type => 'application/grammar+grxml' }
|
|
112
114
|
|
|
113
|
-
its(:content_type) { should == 'application/grammar+grxml' }
|
|
115
|
+
its(:content_type) { should be == 'application/grammar+grxml' }
|
|
114
116
|
|
|
115
117
|
let(:expected_message) { "<![CDATA[ #{grxml_doc} ]]>" }
|
|
116
118
|
|
|
117
119
|
it "should wrap GRXML in CDATA" do
|
|
118
|
-
subject.child.to_xml.should == expected_message.strip
|
|
120
|
+
subject.child.to_xml.should be == expected_message.strip
|
|
119
121
|
end
|
|
120
122
|
|
|
121
|
-
its(:value) { should == grxml_doc }
|
|
123
|
+
its(:value) { should be == grxml_doc }
|
|
122
124
|
|
|
123
125
|
describe "comparison" do
|
|
124
126
|
let(:grammar2) { Input::Grammar.new :value => '<grammar xmlns="http://www.w3.org/2001/06/grammar" version="1.0" xml:lang="en-US" mode="dtmf" root="digits"><rule id="digits"><one-of><item>0</item><item>1</item></one-of></rule></grammar>' }
|
|
125
127
|
let(:grammar3) { Input::Grammar.new :value => grxml_doc }
|
|
126
128
|
let(:grammar4) { Input::Grammar.new :value => grxml_doc(:speech) }
|
|
127
129
|
|
|
128
|
-
it { should == grammar2 }
|
|
129
|
-
it { should == grammar3 }
|
|
130
|
-
it { should_not == grammar4 }
|
|
130
|
+
it { should be == grammar2 }
|
|
131
|
+
it { should be == grammar3 }
|
|
132
|
+
it { should_not be == grammar4 }
|
|
131
133
|
end
|
|
132
134
|
end
|
|
133
135
|
end
|
|
@@ -145,9 +147,9 @@ module Punchblock
|
|
|
145
147
|
describe '#stop_action' do
|
|
146
148
|
subject { command.stop_action }
|
|
147
149
|
|
|
148
|
-
its(:to_xml) { should == '<stop xmlns="urn:xmpp:rayo:1"/>' }
|
|
149
|
-
its(:component_id) { should == 'abc123' }
|
|
150
|
-
its(:call_id) { should == '123abc' }
|
|
150
|
+
its(:to_xml) { should be == '<stop xmlns="urn:xmpp:rayo:1"/>' }
|
|
151
|
+
its(:component_id) { should be == 'abc123' }
|
|
152
|
+
its(:call_id) { should be == '123abc' }
|
|
151
153
|
end
|
|
152
154
|
|
|
153
155
|
describe '#stop!' do
|
|
@@ -187,11 +189,11 @@ module Punchblock
|
|
|
187
189
|
|
|
188
190
|
it { should be_instance_of Input::Complete::Success }
|
|
189
191
|
|
|
190
|
-
its(:name) { should == :success }
|
|
191
|
-
its(:mode) { should == :speech }
|
|
192
|
-
its(:confidence) { should == 0.45 }
|
|
193
|
-
its(:interpretation) { should == '1234' }
|
|
194
|
-
its(:utterance) { should == 'one two three four' }
|
|
192
|
+
its(:name) { should be == :success }
|
|
193
|
+
its(:mode) { should be == :speech }
|
|
194
|
+
its(:confidence) { should be == 0.45 }
|
|
195
|
+
its(:interpretation) { should be == '1234' }
|
|
196
|
+
its(:utterance) { should be == 'one two three four' }
|
|
195
197
|
|
|
196
198
|
describe "when setting options in initializer" do
|
|
197
199
|
subject do
|
|
@@ -202,10 +204,10 @@ module Punchblock
|
|
|
202
204
|
end
|
|
203
205
|
|
|
204
206
|
|
|
205
|
-
its(:mode) { should == :dtmf }
|
|
206
|
-
its(:confidence) { should == 1 }
|
|
207
|
-
its(:utterance) { should == '123' }
|
|
208
|
-
its(:interpretation) { should == 'dtmf-1 dtmf-2 dtmf-3' }
|
|
207
|
+
its(:mode) { should be == :dtmf }
|
|
208
|
+
its(:confidence) { should be == 1 }
|
|
209
|
+
its(:utterance) { should be == '123' }
|
|
210
|
+
its(:interpretation) { should be == 'dtmf-1 dtmf-2 dtmf-3' }
|
|
209
211
|
end
|
|
210
212
|
end
|
|
211
213
|
|
|
@@ -222,7 +224,7 @@ module Punchblock
|
|
|
222
224
|
|
|
223
225
|
it { should be_instance_of Input::Complete::NoMatch }
|
|
224
226
|
|
|
225
|
-
its(:name) { should == :nomatch }
|
|
227
|
+
its(:name) { should be == :nomatch }
|
|
226
228
|
end
|
|
227
229
|
|
|
228
230
|
describe Input::Complete::NoInput do
|
|
@@ -238,7 +240,7 @@ module Punchblock
|
|
|
238
240
|
|
|
239
241
|
it { should be_instance_of Input::Complete::NoInput }
|
|
240
242
|
|
|
241
|
-
its(:name) { should == :noinput }
|
|
243
|
+
its(:name) { should be == :noinput }
|
|
242
244
|
end
|
|
243
245
|
end
|
|
244
246
|
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
module Punchblock
|
|
4
6
|
module Component
|
|
5
7
|
describe Output do
|
|
6
8
|
it 'registers itself' do
|
|
7
|
-
RayoNode.class_from_registration(:output, 'urn:xmpp:rayo:output:1').should == Output
|
|
9
|
+
RayoNode.class_from_registration(:output, 'urn:xmpp:rayo:output:1').should be == Output
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
describe 'default values' do
|
|
@@ -28,13 +30,13 @@ module Punchblock
|
|
|
28
30
|
:voice => 'allison'
|
|
29
31
|
end
|
|
30
32
|
|
|
31
|
-
its(:interrupt_on) { should == :speech }
|
|
32
|
-
its(:start_offset) { should == 2000 }
|
|
33
|
-
its(:start_paused) { should == false }
|
|
34
|
-
its(:repeat_interval) { should == 2000 }
|
|
35
|
-
its(:repeat_times) { should == 10 }
|
|
36
|
-
its(:max_time) { should == 30000 }
|
|
37
|
-
its(:voice) { should == 'allison' }
|
|
33
|
+
its(:interrupt_on) { should be == :speech }
|
|
34
|
+
its(:start_offset) { should be == 2000 }
|
|
35
|
+
its(:start_paused) { should be == false }
|
|
36
|
+
its(:repeat_interval) { should be == 2000 }
|
|
37
|
+
its(:repeat_times) { should be == 10 }
|
|
38
|
+
its(:max_time) { should be == 30000 }
|
|
39
|
+
its(:voice) { should be == 'allison' }
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
describe "from a stanza" do
|
|
@@ -55,21 +57,21 @@ module Punchblock
|
|
|
55
57
|
|
|
56
58
|
it { should be_instance_of Output }
|
|
57
59
|
|
|
58
|
-
its(:interrupt_on) { should == :speech }
|
|
59
|
-
its(:start_offset) { should == 2000 }
|
|
60
|
-
its(:start_paused) { should == false }
|
|
61
|
-
its(:repeat_interval) { should == 2000 }
|
|
62
|
-
its(:repeat_times) { should == 10 }
|
|
63
|
-
its(:max_time) { should == 30000 }
|
|
64
|
-
its(:voice) { should == 'allison' }
|
|
65
|
-
its(:text) { should == 'Hello world' }
|
|
60
|
+
its(:interrupt_on) { should be == :speech }
|
|
61
|
+
its(:start_offset) { should be == 2000 }
|
|
62
|
+
its(:start_paused) { should be == false }
|
|
63
|
+
its(:repeat_interval) { should be == 2000 }
|
|
64
|
+
its(:repeat_times) { should be == 10 }
|
|
65
|
+
its(:max_time) { should be == 30000 }
|
|
66
|
+
its(:voice) { should be == 'allison' }
|
|
67
|
+
its(:text) { should be == 'Hello world' }
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
describe "for text" do
|
|
69
71
|
subject { Output.new :text => 'Once upon a time there was a message...', :voice => 'kate' }
|
|
70
72
|
|
|
71
|
-
its(:voice) { should == 'kate' }
|
|
72
|
-
its(:text) { should == 'Once upon a time there was a message...' }
|
|
73
|
+
its(:voice) { should be == 'kate' }
|
|
74
|
+
its(:text) { should be == 'Once upon a time there was a message...' }
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
describe "for SSML" do
|
|
@@ -81,18 +83,18 @@ module Punchblock
|
|
|
81
83
|
|
|
82
84
|
subject { Output.new :ssml => ssml_doc, :voice => 'kate' }
|
|
83
85
|
|
|
84
|
-
its(:voice) { should == 'kate' }
|
|
86
|
+
its(:voice) { should be == 'kate' }
|
|
85
87
|
|
|
86
|
-
its(:ssml) { should == ssml_doc }
|
|
88
|
+
its(:ssml) { should be == ssml_doc }
|
|
87
89
|
|
|
88
90
|
describe "comparison" do
|
|
89
91
|
let(:output2) { Output.new :ssml => '<speak xmlns="http://www.w3.org/2001/10/synthesis" version="1.0" xml:lang="en-US"><say-as interpret-as="ordinal"/></speak>', :voice => 'kate' }
|
|
90
92
|
let(:output3) { Output.new :ssml => ssml_doc, :voice => 'kate' }
|
|
91
93
|
let(:output4) { Output.new :ssml => ssml_doc(:normal), :voice => 'kate' }
|
|
92
94
|
|
|
93
|
-
it { should == output2 }
|
|
94
|
-
it { should == output3 }
|
|
95
|
-
it { should_not == output4 }
|
|
95
|
+
it { should be == output2 }
|
|
96
|
+
it { should be == output3 }
|
|
97
|
+
it { should_not be == output4 }
|
|
96
98
|
end
|
|
97
99
|
end
|
|
98
100
|
|
|
@@ -109,9 +111,9 @@ module Punchblock
|
|
|
109
111
|
describe '#pause_action' do
|
|
110
112
|
subject { command.pause_action }
|
|
111
113
|
|
|
112
|
-
its(:to_xml) { should == '<pause xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
113
|
-
its(:component_id) { should == 'abc123' }
|
|
114
|
-
its(:call_id) { should == '123abc' }
|
|
114
|
+
its(:to_xml) { should be == '<pause xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
115
|
+
its(:component_id) { should be == 'abc123' }
|
|
116
|
+
its(:call_id) { should be == '123abc' }
|
|
115
117
|
end
|
|
116
118
|
|
|
117
119
|
describe '#pause!' do
|
|
@@ -142,7 +144,7 @@ module Punchblock
|
|
|
142
144
|
subject.paused!
|
|
143
145
|
end
|
|
144
146
|
|
|
145
|
-
its(:state_name) { should == :paused }
|
|
147
|
+
its(:state_name) { should be == :paused }
|
|
146
148
|
|
|
147
149
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
148
150
|
lambda { subject.paused! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -152,9 +154,9 @@ module Punchblock
|
|
|
152
154
|
describe '#resume_action' do
|
|
153
155
|
subject { command.resume_action }
|
|
154
156
|
|
|
155
|
-
its(:to_xml) { should == '<resume xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
156
|
-
its(:component_id) { should == 'abc123' }
|
|
157
|
-
its(:call_id) { should == '123abc' }
|
|
157
|
+
its(:to_xml) { should be == '<resume xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
158
|
+
its(:component_id) { should be == 'abc123' }
|
|
159
|
+
its(:call_id) { should be == '123abc' }
|
|
158
160
|
end
|
|
159
161
|
|
|
160
162
|
describe '#resume!' do
|
|
@@ -187,7 +189,7 @@ module Punchblock
|
|
|
187
189
|
subject.resumed!
|
|
188
190
|
end
|
|
189
191
|
|
|
190
|
-
its(:state_name) { should == :executing }
|
|
192
|
+
its(:state_name) { should be == :executing }
|
|
191
193
|
|
|
192
194
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
193
195
|
lambda { subject.resumed! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -197,9 +199,9 @@ module Punchblock
|
|
|
197
199
|
describe '#stop_action' do
|
|
198
200
|
subject { command.stop_action }
|
|
199
201
|
|
|
200
|
-
its(:to_xml) { should == '<stop xmlns="urn:xmpp:rayo:1"/>' }
|
|
201
|
-
its(:component_id) { should == 'abc123' }
|
|
202
|
-
its(:call_id) { should == '123abc' }
|
|
202
|
+
its(:to_xml) { should be == '<stop xmlns="urn:xmpp:rayo:1"/>' }
|
|
203
|
+
its(:component_id) { should be == 'abc123' }
|
|
204
|
+
its(:call_id) { should be == '123abc' }
|
|
203
205
|
end
|
|
204
206
|
|
|
205
207
|
describe '#stop!' do
|
|
@@ -228,9 +230,9 @@ module Punchblock
|
|
|
228
230
|
describe '#seek_action' do
|
|
229
231
|
subject { command.seek_action seek_options }
|
|
230
232
|
|
|
231
|
-
its(:to_xml) { should == '<seek xmlns="urn:xmpp:rayo:output:1" direction="forward" amount="1500"/>' }
|
|
232
|
-
its(:component_id) { should == 'abc123' }
|
|
233
|
-
its(:call_id) { should == '123abc' }
|
|
233
|
+
its(:to_xml) { should be == '<seek xmlns="urn:xmpp:rayo:output:1" direction="forward" amount="1500"/>' }
|
|
234
|
+
its(:component_id) { should be == 'abc123' }
|
|
235
|
+
its(:call_id) { should be == '123abc' }
|
|
234
236
|
end
|
|
235
237
|
|
|
236
238
|
describe '#seek!' do
|
|
@@ -268,7 +270,7 @@ module Punchblock
|
|
|
268
270
|
subject.seeking!
|
|
269
271
|
end
|
|
270
272
|
|
|
271
|
-
its(:seek_status_name) { should == :seeking }
|
|
273
|
+
its(:seek_status_name) { should be == :seeking }
|
|
272
274
|
|
|
273
275
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
274
276
|
lambda { subject.seeking! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -283,7 +285,7 @@ module Punchblock
|
|
|
283
285
|
subject.stopped_seeking!
|
|
284
286
|
end
|
|
285
287
|
|
|
286
|
-
its(:seek_status_name) { should == :not_seeking }
|
|
288
|
+
its(:seek_status_name) { should be == :not_seeking }
|
|
287
289
|
|
|
288
290
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
289
291
|
lambda { subject.stopped_seeking! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -295,9 +297,9 @@ module Punchblock
|
|
|
295
297
|
describe '#speed_up_action' do
|
|
296
298
|
subject { command.speed_up_action }
|
|
297
299
|
|
|
298
|
-
its(:to_xml) { should == '<speed-up xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
299
|
-
its(:component_id) { should == 'abc123' }
|
|
300
|
-
its(:call_id) { should == '123abc' }
|
|
300
|
+
its(:to_xml) { should be == '<speed-up xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
301
|
+
its(:component_id) { should be == 'abc123' }
|
|
302
|
+
its(:call_id) { should be == '123abc' }
|
|
301
303
|
end
|
|
302
304
|
|
|
303
305
|
describe '#speed_up!' do
|
|
@@ -343,7 +345,7 @@ module Punchblock
|
|
|
343
345
|
subject.speeding_up!
|
|
344
346
|
end
|
|
345
347
|
|
|
346
|
-
its(:speed_status_name) { should == :speeding_up }
|
|
348
|
+
its(:speed_status_name) { should be == :speeding_up }
|
|
347
349
|
|
|
348
350
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
349
351
|
lambda { subject.speeding_up! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -353,9 +355,9 @@ module Punchblock
|
|
|
353
355
|
describe '#slow_down_action' do
|
|
354
356
|
subject { command.slow_down_action }
|
|
355
357
|
|
|
356
|
-
its(:to_xml) { should == '<speed-down xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
357
|
-
its(:component_id) { should == 'abc123' }
|
|
358
|
-
its(:call_id) { should == '123abc' }
|
|
358
|
+
its(:to_xml) { should be == '<speed-down xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
359
|
+
its(:component_id) { should be == 'abc123' }
|
|
360
|
+
its(:call_id) { should be == '123abc' }
|
|
359
361
|
end
|
|
360
362
|
|
|
361
363
|
describe '#slow_down!' do
|
|
@@ -401,7 +403,7 @@ module Punchblock
|
|
|
401
403
|
subject.slowing_down!
|
|
402
404
|
end
|
|
403
405
|
|
|
404
|
-
its(:speed_status_name) { should == :slowing_down }
|
|
406
|
+
its(:speed_status_name) { should be == :slowing_down }
|
|
405
407
|
|
|
406
408
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
407
409
|
lambda { subject.slowing_down! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -416,7 +418,7 @@ module Punchblock
|
|
|
416
418
|
subject.stopped_speeding!
|
|
417
419
|
end
|
|
418
420
|
|
|
419
|
-
its(:speed_status_name) { should == :not_speeding }
|
|
421
|
+
its(:speed_status_name) { should be == :not_speeding }
|
|
420
422
|
|
|
421
423
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
422
424
|
lambda { subject.stopped_speeding! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -428,9 +430,9 @@ module Punchblock
|
|
|
428
430
|
describe '#volume_up_action' do
|
|
429
431
|
subject { command.volume_up_action }
|
|
430
432
|
|
|
431
|
-
its(:to_xml) { should == '<volume-up xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
432
|
-
its(:component_id) { should == 'abc123' }
|
|
433
|
-
its(:call_id) { should == '123abc' }
|
|
433
|
+
its(:to_xml) { should be == '<volume-up xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
434
|
+
its(:component_id) { should be == 'abc123' }
|
|
435
|
+
its(:call_id) { should be == '123abc' }
|
|
434
436
|
end
|
|
435
437
|
|
|
436
438
|
describe '#volume_up!' do
|
|
@@ -476,7 +478,7 @@ module Punchblock
|
|
|
476
478
|
subject.voluming_up!
|
|
477
479
|
end
|
|
478
480
|
|
|
479
|
-
its(:volume_status_name) { should == :voluming_up }
|
|
481
|
+
its(:volume_status_name) { should be == :voluming_up }
|
|
480
482
|
|
|
481
483
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
482
484
|
lambda { subject.voluming_up! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -486,9 +488,9 @@ module Punchblock
|
|
|
486
488
|
describe '#volume_down_action' do
|
|
487
489
|
subject { command.volume_down_action }
|
|
488
490
|
|
|
489
|
-
its(:to_xml) { should == '<volume-down xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
490
|
-
its(:component_id) { should == 'abc123' }
|
|
491
|
-
its(:call_id) { should == '123abc' }
|
|
491
|
+
its(:to_xml) { should be == '<volume-down xmlns="urn:xmpp:rayo:output:1"/>' }
|
|
492
|
+
its(:component_id) { should be == 'abc123' }
|
|
493
|
+
its(:call_id) { should be == '123abc' }
|
|
492
494
|
end
|
|
493
495
|
|
|
494
496
|
describe '#volume_down!' do
|
|
@@ -534,7 +536,7 @@ module Punchblock
|
|
|
534
536
|
subject.voluming_down!
|
|
535
537
|
end
|
|
536
538
|
|
|
537
|
-
its(:volume_status_name) { should == :voluming_down }
|
|
539
|
+
its(:volume_status_name) { should be == :voluming_down }
|
|
538
540
|
|
|
539
541
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
540
542
|
lambda { subject.voluming_down! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -549,7 +551,7 @@ module Punchblock
|
|
|
549
551
|
subject.stopped_voluming!
|
|
550
552
|
end
|
|
551
553
|
|
|
552
|
-
its(:volume_status_name) { should == :not_voluming }
|
|
554
|
+
its(:volume_status_name) { should be == :not_voluming }
|
|
553
555
|
|
|
554
556
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
555
557
|
lambda { subject.stopped_voluming! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -572,7 +574,7 @@ module Punchblock
|
|
|
572
574
|
|
|
573
575
|
it { should be_instance_of Output::Complete::Success }
|
|
574
576
|
|
|
575
|
-
its(:name) { should == :success }
|
|
577
|
+
its(:name) { should be == :success }
|
|
576
578
|
end
|
|
577
579
|
end
|
|
578
580
|
end # Punchblock
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
module Punchblock
|
|
4
6
|
module Component
|
|
5
7
|
describe Record do
|
|
6
8
|
it 'registers itself' do
|
|
7
|
-
RayoNode.class_from_registration(:record, 'urn:xmpp:rayo:record:1').should == Record
|
|
9
|
+
RayoNode.class_from_registration(:record, 'urn:xmpp:rayo:record:1').should be == Record
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
describe "when setting options in initializer" do
|
|
@@ -18,13 +20,13 @@ module Punchblock
|
|
|
18
20
|
:final_timeout => 30000
|
|
19
21
|
end
|
|
20
22
|
|
|
21
|
-
its(:format) { should == 'WAV' }
|
|
22
|
-
its(:start_beep) { should == true }
|
|
23
|
-
its(:start_paused) { should == false }
|
|
24
|
-
its(:stop_beep) { should == true }
|
|
25
|
-
its(:max_duration) { should == 500000 }
|
|
26
|
-
its(:initial_timeout) { should == 10000 }
|
|
27
|
-
its(:final_timeout) { should == 30000 }
|
|
23
|
+
its(:format) { should be == 'WAV' }
|
|
24
|
+
its(:start_beep) { should be == true }
|
|
25
|
+
its(:start_paused) { should be == false }
|
|
26
|
+
its(:stop_beep) { should be == true }
|
|
27
|
+
its(:max_duration) { should be == 500000 }
|
|
28
|
+
its(:initial_timeout) { should be == 10000 }
|
|
29
|
+
its(:final_timeout) { should be == 30000 }
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
describe "from a stanza" do
|
|
@@ -45,13 +47,13 @@ module Punchblock
|
|
|
45
47
|
|
|
46
48
|
it { should be_instance_of Record }
|
|
47
49
|
|
|
48
|
-
its(:format) { should == 'WAV' }
|
|
49
|
-
its(:start_beep) { should == true }
|
|
50
|
-
its(:start_paused) { should == false }
|
|
51
|
-
its(:stop_beep) { should == true }
|
|
52
|
-
its(:max_duration) { should == 500000 }
|
|
53
|
-
its(:initial_timeout) { should == 10000 }
|
|
54
|
-
its(:final_timeout) { should == 30000 }
|
|
50
|
+
its(:format) { should be == 'WAV' }
|
|
51
|
+
its(:start_beep) { should be == true }
|
|
52
|
+
its(:start_paused) { should be == false }
|
|
53
|
+
its(:stop_beep) { should be == true }
|
|
54
|
+
its(:max_duration) { should be == 500000 }
|
|
55
|
+
its(:initial_timeout) { should be == 10000 }
|
|
56
|
+
its(:final_timeout) { should be == 30000 }
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
describe "actions" do
|
|
@@ -67,9 +69,9 @@ module Punchblock
|
|
|
67
69
|
describe '#pause_action' do
|
|
68
70
|
subject { command.pause_action }
|
|
69
71
|
|
|
70
|
-
its(:to_xml) { should == '<pause xmlns="urn:xmpp:rayo:record:1"/>' }
|
|
71
|
-
its(:component_id) { should == 'abc123' }
|
|
72
|
-
its(:call_id) { should == '123abc' }
|
|
72
|
+
its(:to_xml) { should be == '<pause xmlns="urn:xmpp:rayo:record:1"/>' }
|
|
73
|
+
its(:component_id) { should be == 'abc123' }
|
|
74
|
+
its(:call_id) { should be == '123abc' }
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
describe '#pause!' do
|
|
@@ -100,7 +102,7 @@ module Punchblock
|
|
|
100
102
|
subject.paused!
|
|
101
103
|
end
|
|
102
104
|
|
|
103
|
-
its(:state_name) { should == :paused }
|
|
105
|
+
its(:state_name) { should be == :paused }
|
|
104
106
|
|
|
105
107
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
106
108
|
lambda { subject.paused! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -110,9 +112,9 @@ module Punchblock
|
|
|
110
112
|
describe '#resume_action' do
|
|
111
113
|
subject { command.resume_action }
|
|
112
114
|
|
|
113
|
-
its(:to_xml) { should == '<resume xmlns="urn:xmpp:rayo:record:1"/>' }
|
|
114
|
-
its(:component_id) { should == 'abc123' }
|
|
115
|
-
its(:call_id) { should == '123abc' }
|
|
115
|
+
its(:to_xml) { should be == '<resume xmlns="urn:xmpp:rayo:record:1"/>' }
|
|
116
|
+
its(:component_id) { should be == 'abc123' }
|
|
117
|
+
its(:call_id) { should be == '123abc' }
|
|
116
118
|
end
|
|
117
119
|
|
|
118
120
|
describe '#resume!' do
|
|
@@ -145,7 +147,7 @@ module Punchblock
|
|
|
145
147
|
subject.resumed!
|
|
146
148
|
end
|
|
147
149
|
|
|
148
|
-
its(:state_name) { should == :executing }
|
|
150
|
+
its(:state_name) { should be == :executing }
|
|
149
151
|
|
|
150
152
|
it "should raise a StateMachine::InvalidTransition when received a second time" do
|
|
151
153
|
lambda { subject.resumed! }.should raise_error(StateMachine::InvalidTransition)
|
|
@@ -155,9 +157,9 @@ module Punchblock
|
|
|
155
157
|
describe '#stop_action' do
|
|
156
158
|
subject { command.stop_action }
|
|
157
159
|
|
|
158
|
-
its(:to_xml) { should == '<stop xmlns="urn:xmpp:rayo:1"/>' }
|
|
159
|
-
its(:component_id) { should == 'abc123' }
|
|
160
|
-
its(:call_id) { should == '123abc' }
|
|
160
|
+
its(:to_xml) { should be == '<stop xmlns="urn:xmpp:rayo:1"/>' }
|
|
161
|
+
its(:component_id) { should be == 'abc123' }
|
|
162
|
+
its(:call_id) { should be == '123abc' }
|
|
161
163
|
end
|
|
162
164
|
|
|
163
165
|
describe '#stop!' do
|
|
@@ -196,16 +198,16 @@ module Punchblock
|
|
|
196
198
|
|
|
197
199
|
it { should be_instance_of Record::Complete::Success }
|
|
198
200
|
|
|
199
|
-
its(:name) { should == :success }
|
|
201
|
+
its(:name) { should be == :success }
|
|
200
202
|
end
|
|
201
203
|
|
|
202
204
|
describe "#recording" do
|
|
203
205
|
subject { RayoNode.import(parse_stanza(stanza).root).recording }
|
|
204
206
|
|
|
205
207
|
it { should be_instance_of Record::Recording }
|
|
206
|
-
its(:uri) { should == "file:/tmp/rayo7451601434771683422.mp3" }
|
|
207
|
-
its(:duration) { should == 34000 }
|
|
208
|
-
its(:size) { should == 23450 }
|
|
208
|
+
its(:uri) { should be == "file:/tmp/rayo7451601434771683422.mp3" }
|
|
209
|
+
its(:duration) { should be == 34000 }
|
|
210
|
+
its(:size) { should be == 23450 }
|
|
209
211
|
end
|
|
210
212
|
end
|
|
211
213
|
|
|
@@ -224,14 +226,14 @@ module Punchblock
|
|
|
224
226
|
|
|
225
227
|
it { should be_instance_of Event::Complete::Stop }
|
|
226
228
|
|
|
227
|
-
its(:name) { should == :stop }
|
|
229
|
+
its(:name) { should be == :stop }
|
|
228
230
|
end
|
|
229
231
|
|
|
230
232
|
describe "#recording" do
|
|
231
233
|
subject { RayoNode.import(parse_stanza(stanza).root).recording }
|
|
232
234
|
|
|
233
235
|
it { should be_instance_of Record::Recording }
|
|
234
|
-
its(:uri) { should == "file:/tmp/rayo7451601434771683422.mp3" }
|
|
236
|
+
its(:uri) { should be == "file:/tmp/rayo7451601434771683422.mp3" }
|
|
235
237
|
end
|
|
236
238
|
end
|
|
237
239
|
|
|
@@ -250,14 +252,14 @@ module Punchblock
|
|
|
250
252
|
|
|
251
253
|
it { should be_instance_of Event::Complete::Hangup }
|
|
252
254
|
|
|
253
|
-
its(:name) { should == :hangup }
|
|
255
|
+
its(:name) { should be == :hangup }
|
|
254
256
|
end
|
|
255
257
|
|
|
256
258
|
describe "#recording" do
|
|
257
259
|
subject { RayoNode.import(parse_stanza(stanza).root).recording }
|
|
258
260
|
|
|
259
261
|
it { should be_instance_of Record::Recording }
|
|
260
|
-
its(:uri) { should == "file:/tmp/rayo7451601434771683422.mp3" }
|
|
262
|
+
its(:uri) { should be == "file:/tmp/rayo7451601434771683422.mp3" }
|
|
261
263
|
end
|
|
262
264
|
end
|
|
263
265
|
end
|