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 Command
7
7
  describe Unmute do
8
8
  it 'registers itself' do
9
- RayoNode.class_from_registration(:unmute, 'urn:xmpp:rayo:1').should be == described_class
9
+ expect(RayoNode.class_from_registration(:unmute, 'urn:xmpp:rayo:1')).to eq(described_class)
10
10
  end
11
11
 
12
12
  describe "from a stanza" do
@@ -20,7 +20,7 @@ module Punchblock
20
20
  describe "exporting to Rayo" do
21
21
  it "should export to XML that can be understood by its parser" do
22
22
  new_instance = RayoNode.from_xml subject.to_rayo
23
- new_instance.should be_instance_of described_class
23
+ expect(new_instance).to be_instance_of described_class
24
24
  end
25
25
 
26
26
  it "should render to a parent node if supplied" do
@@ -28,7 +28,7 @@ module Punchblock
28
28
  parent = Nokogiri::XML::Node.new 'foo', doc
29
29
  doc.root = parent
30
30
  rayo_doc = subject.to_rayo(parent)
31
- rayo_doc.should == parent
31
+ expect(rayo_doc).to eq(parent)
32
32
  end
33
33
  end
34
34
  end
@@ -6,12 +6,19 @@ module Punchblock
6
6
  module Command
7
7
  describe CommandNode do
8
8
  let(:args) { [] }
9
- subject do
9
+ subject(:command) do
10
10
  Class.new(described_class) { register 'foo'}.new(*args)
11
11
  end
12
12
 
13
- its(:state_name) { should be == :new }
14
- its(:request_id) { should be == @uuid }
13
+ describe '#state_name' do
14
+ subject { super().state_name }
15
+ it { should be == :new }
16
+ end
17
+
18
+ describe '#request_id' do
19
+ subject { super().request_id }
20
+ it { should be == @uuid }
21
+ end
15
22
 
16
23
  describe "#new" do
17
24
  describe "with a call/component ID" do
@@ -19,62 +26,78 @@ module Punchblock
19
26
  let(:component_id) { 'abc123' }
20
27
  let(:args) { [{:target_call_id => call_id, :component_id => component_id}] }
21
28
 
22
- its(:target_call_id) { should be == call_id }
23
- its(:component_id) { should be == component_id }
29
+ describe '#target_call_id' do
30
+ subject { super().target_call_id }
31
+ it { should be == call_id }
32
+ end
33
+
34
+ describe '#component_id' do
35
+ subject { super().component_id }
36
+ it { should be == component_id }
37
+ end
24
38
  end
25
39
  end
26
40
 
27
41
  describe "#request!" do
28
- before { subject.request! }
42
+ before { command.request! }
29
43
 
30
- its(:state_name) { should be == :requested }
44
+ describe '#state_name' do
45
+ subject { command.state_name }
46
+ it { should be == :requested }
47
+ end
31
48
 
32
49
  it "should raise a StateMachine::InvalidTransition when received a second time" do
33
- lambda { subject.request! }.should raise_error(StateMachine::InvalidTransition)
50
+ expect { command.request! }.to raise_error(StateMachine::InvalidTransition)
34
51
  end
35
52
  end
36
53
 
37
54
  describe "#execute!" do
38
55
  describe "without sending" do
39
56
  it "should raise a StateMachine::InvalidTransition" do
40
- lambda { subject.execute! }.should raise_error(StateMachine::InvalidTransition)
57
+ expect { subject.execute! }.to raise_error(StateMachine::InvalidTransition)
41
58
  end
42
59
  end
43
60
 
44
61
  describe "after sending" do
45
62
  before do
46
- subject.request!
47
- subject.execute!
63
+ command.request!
64
+ command.execute!
48
65
  end
49
66
 
50
- its(:state_name) { should be == :executing }
67
+ describe '#state_name' do
68
+ subject { super().state_name }
69
+ it { should be == :executing }
70
+ end
51
71
  end
52
72
  end
53
73
 
54
74
  describe "#complete!" do
55
75
  before do
56
- subject.request!
57
- subject.execute!
58
- subject.complete!
76
+ command.request!
77
+ command.execute!
78
+ command.complete!
59
79
  end
60
80
 
61
- its(:state_name) { should be == :complete }
81
+ describe '#state_name' do
82
+ subject { super().state_name }
83
+ it { should be == :complete }
84
+ end
62
85
 
63
86
  it "should raise a StateMachine::InvalidTransition when received a second time" do
64
- lambda { subject.complete! }.should raise_error(StateMachine::InvalidTransition)
87
+ expect { subject.complete! }.to raise_error(StateMachine::InvalidTransition)
65
88
  end
66
89
  end # #complete!
67
90
 
68
91
  describe "#response=" do
69
92
  it "should set the command to executing status" do
70
- subject.should_receive(:execute!).once
93
+ expect(subject).to receive(:execute!).once
71
94
  subject.response = :foo
72
95
  end
73
96
 
74
97
  it "should be a no-op if the response has already been set" do
75
- subject.should_receive(:execute!).once
98
+ expect(subject).to receive(:execute!).once
76
99
  subject.response = :foo
77
- lambda { subject.response = :bar }.should_not raise_error
100
+ expect { subject.response = :bar }.not_to raise_error
78
101
  end
79
102
  end
80
103
  end # CommandNode
@@ -8,7 +8,7 @@ module Punchblock
8
8
  module AGI
9
9
  describe Command do
10
10
  it 'registers itself' do
11
- RayoNode.class_from_registration(:command, 'urn:xmpp:rayo:asterisk:agi:1').should be == described_class
11
+ expect(RayoNode.class_from_registration(:command, 'urn:xmpp:rayo:asterisk:agi:1')).to eq(described_class)
12
12
  end
13
13
 
14
14
  describe "from a stanza" do
@@ -26,8 +26,15 @@ module Punchblock
26
26
 
27
27
  it_should_behave_like 'event'
28
28
 
29
- its(:name) { should be == 'GET VARIABLE' }
30
- its(:params) { should be == ['UNIQUEID'] }
29
+ describe '#name' do
30
+ subject { super().name }
31
+ it { should be == 'GET VARIABLE' }
32
+ end
33
+
34
+ describe '#params' do
35
+ subject { super().params }
36
+ it { should be == ['UNIQUEID'] }
37
+ end
31
38
  end
32
39
 
33
40
  describe "when setting options in initializer" do
@@ -36,8 +43,15 @@ module Punchblock
36
43
  params: ['UNIQUEID']
37
44
  end
38
45
 
39
- its(:name) { should be == 'GET VARIABLE' }
40
- its(:params) { should be == ['UNIQUEID'] }
46
+ describe '#name' do
47
+ subject { super().name }
48
+ it { should be == 'GET VARIABLE' }
49
+ end
50
+
51
+ describe '#params' do
52
+ subject { super().params }
53
+ it { should be == ['UNIQUEID'] }
54
+ end
41
55
  end
42
56
 
43
57
  class Command
@@ -58,19 +72,45 @@ module Punchblock
58
72
 
59
73
  it { should be_instance_of described_class }
60
74
 
61
- its(:name) { should be == :success }
62
- its(:code) { should be == 200 }
63
- its(:result) { should be == 0 }
64
- its(:data) { should be == '1187188485.0' }
75
+ describe '#name' do
76
+ subject { super().name }
77
+ it { should be == :success }
78
+ end
79
+
80
+ describe '#code' do
81
+ subject { super().code }
82
+ it { should be == 200 }
83
+ end
84
+
85
+ describe '#result' do
86
+ subject { super().result }
87
+ it { should be == 0 }
88
+ end
89
+
90
+ describe '#data' do
91
+ subject { super().data }
92
+ it { should be == '1187188485.0' }
93
+ end
65
94
 
66
95
  describe "when setting options in initializer" do
67
96
  subject do
68
97
  Complete::Success.new code: 200, result: 0, data: '1187188485.0'
69
98
  end
70
99
 
71
- its(:code) { should be == 200 }
72
- its(:result) { should be == 0 }
73
- its(:data) { should be == '1187188485.0' }
100
+ describe '#code' do
101
+ subject { super().code }
102
+ it { should be == 200 }
103
+ end
104
+
105
+ describe '#result' do
106
+ subject { super().result }
107
+ it { should be == 0 }
108
+ end
109
+
110
+ describe '#data' do
111
+ subject { super().data }
112
+ it { should be == '1187188485.0' }
113
+ end
74
114
  end
75
115
  end
76
116
  end
@@ -8,7 +8,7 @@ module Punchblock
8
8
  module AMI
9
9
  describe Action do
10
10
  it 'registers itself' do
11
- RayoNode.class_from_registration(:action, 'urn:xmpp:rayo:asterisk:ami:1').should be == described_class
11
+ expect(RayoNode.class_from_registration(:action, 'urn:xmpp:rayo:asterisk:ami:1')).to eq(described_class)
12
12
  end
13
13
 
14
14
  describe "from a stanza" do
@@ -33,8 +33,14 @@ module Punchblock
33
33
 
34
34
  it_should_behave_like 'event'
35
35
 
36
- its(:name) { should be == 'Originate' }
37
- its(:params) { should be == { 'Channel' => 'SIP/101test',
36
+ describe '#name' do
37
+ subject { super().name }
38
+ it { should be == 'Originate' }
39
+ end
40
+
41
+ describe '#params' do
42
+ subject { super().params }
43
+ it { should be == { 'Channel' => 'SIP/101test',
38
44
  'Context' => 'default',
39
45
  'Exten' => '8135551212',
40
46
  'Priority' => '1',
@@ -42,24 +48,25 @@ module Punchblock
42
48
  'Timeout' => '30000',
43
49
  'Variable' => 'var1=23|var2=24|var3=25',
44
50
  'Async' => '1'} }
51
+ end
45
52
  end
46
53
 
47
54
  describe "testing equality" do
48
55
  context "with the same name and params" do
49
56
  it "should be equal" do
50
- Action.new(:name => 'Originate', :params => { :channel => 'SIP/101test' }).should be == Action.new(:name => 'Originate', :params => { :channel => 'SIP/101test' })
57
+ expect(Action.new(:name => 'Originate', :params => { :channel => 'SIP/101test' })).to eq(Action.new(:name => 'Originate', :params => { :channel => 'SIP/101test' }))
51
58
  end
52
59
  end
53
60
 
54
61
  context "with the same name and different params" do
55
62
  it "should be equal" do
56
- Action.new(:name => 'Originate', :params => { :channel => 'SIP/101' }).should_not be == Action.new(:name => 'Originate', :params => { :channel => 'SIP/101test' })
63
+ expect(Action.new(:name => 'Originate', :params => { :channel => 'SIP/101' })).not_to eq(Action.new(:name => 'Originate', :params => { :channel => 'SIP/101test' }))
57
64
  end
58
65
  end
59
66
 
60
67
  context "with a different name and the same params" do
61
68
  it "should be equal" do
62
- Action.new(:name => 'Hangup', :params => { :channel => 'SIP/101test' }).should_not be == Action.new(:name => 'Originate', :params => { :channel => 'SIP/101test' })
69
+ expect(Action.new(:name => 'Hangup', :params => { :channel => 'SIP/101test' })).not_to eq(Action.new(:name => 'Originate', :params => { :channel => 'SIP/101test' }))
63
70
  end
64
71
  end
65
72
  end
@@ -70,15 +77,22 @@ module Punchblock
70
77
  :params => { 'Channel' => 'SIP/101test' }
71
78
  end
72
79
 
73
- its(:name) { should be == 'Originate' }
74
- its(:params) { should be == { 'Channel' => 'SIP/101test' } }
80
+ describe '#name' do
81
+ subject { super().name }
82
+ it { should be == 'Originate' }
83
+ end
84
+
85
+ describe '#params' do
86
+ subject { super().params }
87
+ it { should be == { 'Channel' => 'SIP/101test' } }
88
+ end
75
89
 
76
90
  describe "exporting to Rayo" do
77
91
  it "should export to XML that can be understood by its parser" do
78
92
  new_instance = RayoNode.from_xml subject.to_rayo
79
- new_instance.should be_instance_of described_class
80
- new_instance.name.should == 'Originate'
81
- new_instance.params.should == { 'Channel' => 'SIP/101test' }
93
+ expect(new_instance).to be_instance_of described_class
94
+ expect(new_instance.name).to eq('Originate')
95
+ expect(new_instance.params).to eq({ 'Channel' => 'SIP/101test' })
82
96
  end
83
97
 
84
98
  it "should render to a parent node if supplied" do
@@ -86,7 +100,7 @@ module Punchblock
86
100
  parent = Nokogiri::XML::Node.new 'foo', doc
87
101
  doc.root = parent
88
102
  rayo_doc = subject.to_rayo(parent)
89
- rayo_doc.should == parent
103
+ expect(rayo_doc).to eq(parent)
90
104
  end
91
105
  end
92
106
  end
@@ -111,21 +125,55 @@ module Punchblock
111
125
 
112
126
  it { should be_instance_of described_class }
113
127
 
114
- its(:name) { should be == :success }
115
- its(:message) { should be == "Originate successfully queued" }
116
- its(:text_body) { should be == 'Some thing happened' }
117
- its(:headers) { should be == {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'} }
118
- its(:attributes) { should be == {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'} } # For BC
128
+ describe '#name' do
129
+ subject { super().name }
130
+ it { should be == :success }
131
+ end
132
+
133
+ describe '#message' do
134
+ subject { super().message }
135
+ it { should be == "Originate successfully queued" }
136
+ end
137
+
138
+ describe '#text_body' do
139
+ subject { super().text_body }
140
+ it { should be == 'Some thing happened' }
141
+ end
142
+
143
+ describe '#headers' do
144
+ subject { super().headers }
145
+ it { should be == {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'} }
146
+ end
147
+
148
+ describe '#attributes' do
149
+ subject { super().attributes }
150
+ it { should be == {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'} }
151
+ end # For BC
119
152
 
120
153
  describe "when setting options in initializer" do
121
154
  subject do
122
155
  described_class.new message: 'Originate successfully queued', text_body: 'Some thing happened', headers: {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}
123
156
  end
124
157
 
125
- its(:message) { should be == 'Originate successfully queued' }
126
- its(:text_body) { should be == 'Some thing happened' }
127
- its(:headers) { should be == {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'} }
128
- its(:attributes) { should be == {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'} } # For BC
158
+ describe '#message' do
159
+ subject { super().message }
160
+ it { should be == 'Originate successfully queued' }
161
+ end
162
+
163
+ describe '#text_body' do
164
+ subject { super().text_body }
165
+ it { should be == 'Some thing happened' }
166
+ end
167
+
168
+ describe '#headers' do
169
+ subject { super().headers }
170
+ it { should be == {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'} }
171
+ end
172
+
173
+ describe '#attributes' do
174
+ subject { super().attributes }
175
+ it { should be == {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'} }
176
+ end # For BC
129
177
  end
130
178
  end
131
179
  end
@@ -24,11 +24,11 @@ module Punchblock
24
24
  describe "with a complete event" do
25
25
  it "should set the complete event resource" do
26
26
  add_event
27
- subject.complete_event(0.5).should be == event
27
+ expect(subject.complete_event(0.5)).to eq(event)
28
28
  end
29
29
 
30
30
  it "should call #complete!" do
31
- subject.should_receive(:complete!).once
31
+ expect(subject).to receive(:complete!).once
32
32
  add_event
33
33
  end
34
34
  end
@@ -38,7 +38,7 @@ module Punchblock
38
38
 
39
39
  it "should not set the complete event resource" do
40
40
  add_event
41
- subject.should_not be_complete
41
+ expect(subject).not_to be_complete
42
42
  end
43
43
  end
44
44
  end # #add_event
@@ -55,7 +55,7 @@ module Punchblock
55
55
  let(:handler) { double 'Response' }
56
56
 
57
57
  before do
58
- handler.should_receive(:call).once.with(event)
58
+ expect(handler).to receive(:call).once.with(event)
59
59
  subject.register_event_handler { |event| handler.call event }
60
60
  end
61
61
 
@@ -79,9 +79,9 @@ module Punchblock
79
79
 
80
80
  it "should set the component ID from the ref" do
81
81
  subject.response = ref
82
- subject.component_id.should be == 'abc123'
83
- subject.source_uri.should be == uri
84
- subject.client.find_component_by_uri(uri).should be subject
82
+ expect(subject.component_id).to eq('abc123')
83
+ expect(subject.source_uri).to eq(uri)
84
+ expect(subject.client.find_component_by_uri(uri)).to be subject
85
85
  end
86
86
  end
87
87
 
@@ -90,23 +90,23 @@ module Punchblock
90
90
  subject.request!
91
91
  subject.client = Client.new
92
92
  subject.response = Ref.new uri: 'abc'
93
- subject.client.find_component_by_uri('abc').should be subject
93
+ expect(subject.client.find_component_by_uri('abc')).to be subject
94
94
  end
95
95
 
96
96
  it "should set the command to executing status" do
97
97
  subject.complete_event = :foo
98
- subject.should be_complete
98
+ expect(subject).to be_complete
99
99
  end
100
100
 
101
101
  it "should be a no-op if the response has already been set" do
102
102
  subject.complete_event = :foo
103
- lambda { subject.complete_event = :bar }.should_not raise_error
104
- subject.complete_event(0.5).should be == :foo
103
+ expect { subject.complete_event = :bar }.not_to raise_error
104
+ expect(subject.complete_event(0.5)).to eq(:foo)
105
105
  end
106
106
 
107
107
  it "should remove the component from the registry" do
108
108
  subject.complete_event = :foo
109
- subject.client.find_component_by_uri('abc').should be_nil
109
+ expect(subject.client.find_component_by_uri('abc')).to be_nil
110
110
  end
111
111
  end
112
112
  end # ComponentNode