punchblock 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
@@ -8,7 +10,8 @@ module Punchblock
|
|
8
10
|
:host => '127.0.0.1',
|
9
11
|
:port => 5038,
|
10
12
|
:username => 'test',
|
11
|
-
:password => 'test'
|
13
|
+
:password => 'test',
|
14
|
+
:media_engine => :swift
|
12
15
|
}
|
13
16
|
end
|
14
17
|
|
@@ -24,16 +27,18 @@ module Punchblock
|
|
24
27
|
|
25
28
|
its(:ami_client) { should be_a RubyAMI::Client }
|
26
29
|
|
27
|
-
after { connection.translator.terminate }
|
28
|
-
|
29
30
|
it 'should set the connection on the translator' do
|
30
31
|
subject.translator.connection.should be subject
|
31
32
|
end
|
32
33
|
|
34
|
+
it 'should set the media engine on the translator' do
|
35
|
+
subject.translator.media_engine.should be == :swift
|
36
|
+
end
|
37
|
+
|
33
38
|
describe '#run' do
|
34
39
|
it 'starts the RubyAMI::Client' do
|
35
40
|
subject.ami_client.expects(:start).once
|
36
|
-
subject.run
|
41
|
+
lambda { subject.run }.should raise_error DisconnectedError
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
@@ -18,41 +20,41 @@ module Punchblock
|
|
18
20
|
context "with no domains specified, and a JID of 1@app.rayo.net" do
|
19
21
|
let(:options) { { :username => '1@app.rayo.net' } }
|
20
22
|
|
21
|
-
its(:root_domain) { should == 'app.rayo.net' }
|
22
|
-
its(:calls_domain) { should == 'calls.app.rayo.net' }
|
23
|
-
its(:mixers_domain) { should == 'mixers.app.rayo.net' }
|
23
|
+
its(:root_domain) { should be == 'app.rayo.net' }
|
24
|
+
its(:calls_domain) { should be == 'calls.app.rayo.net' }
|
25
|
+
its(:mixers_domain) { should be == 'mixers.app.rayo.net' }
|
24
26
|
end
|
25
27
|
|
26
28
|
context "with only a rayo domain set" do
|
27
29
|
let(:options) { { :rayo_domain => 'rayo.org' } }
|
28
30
|
|
29
|
-
its(:root_domain) { should == 'rayo.org' }
|
30
|
-
its(:calls_domain) { should == 'calls.rayo.org' }
|
31
|
-
its(:mixers_domain) { should == 'mixers.rayo.org' }
|
31
|
+
its(:root_domain) { should be == 'rayo.org' }
|
32
|
+
its(:calls_domain) { should be == 'calls.rayo.org' }
|
33
|
+
its(:mixers_domain) { should be == 'mixers.rayo.org' }
|
32
34
|
end
|
33
35
|
|
34
36
|
context "with only a root domain set" do
|
35
37
|
let(:options) { { :root_domain => 'rayo.org' } }
|
36
38
|
|
37
|
-
its(:root_domain) { should == 'rayo.org' }
|
38
|
-
its(:calls_domain) { should == 'calls.rayo.org' }
|
39
|
-
its(:mixers_domain) { should == 'mixers.rayo.org' }
|
39
|
+
its(:root_domain) { should be == 'rayo.org' }
|
40
|
+
its(:calls_domain) { should be == 'calls.rayo.org' }
|
41
|
+
its(:mixers_domain) { should be == 'mixers.rayo.org' }
|
40
42
|
end
|
41
43
|
|
42
44
|
context "with a root domain and calls domain set" do
|
43
45
|
let(:options) { { :root_domain => 'rayo.org', :calls_domain => 'phone_calls.rayo.org' } }
|
44
46
|
|
45
|
-
its(:root_domain) { should == 'rayo.org' }
|
46
|
-
its(:calls_domain) { should == 'phone_calls.rayo.org' }
|
47
|
-
its(:mixers_domain) { should == 'mixers.rayo.org' }
|
47
|
+
its(:root_domain) { should be == 'rayo.org' }
|
48
|
+
its(:calls_domain) { should be == 'phone_calls.rayo.org' }
|
49
|
+
its(:mixers_domain) { should be == 'mixers.rayo.org' }
|
48
50
|
end
|
49
51
|
|
50
52
|
context "with a root domain and mixers domain set" do
|
51
53
|
let(:options) { { :root_domain => 'rayo.org', :mixers_domain => 'conferences.rayo.org' } }
|
52
54
|
|
53
|
-
its(:root_domain) { should == 'rayo.org' }
|
54
|
-
its(:calls_domain) { should == 'calls.rayo.org' }
|
55
|
-
its(:mixers_domain) { should == 'conferences.rayo.org' }
|
55
|
+
its(:root_domain) { should be == 'rayo.org' }
|
56
|
+
its(:calls_domain) { should be == 'calls.rayo.org' }
|
57
|
+
its(:mixers_domain) { should be == 'conferences.rayo.org' }
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
@@ -84,7 +86,6 @@ module Punchblock
|
|
84
86
|
<say-as interpret-as='date'>12/01/2011</say-as>
|
85
87
|
</output>
|
86
88
|
MSG
|
87
|
-
Component::Output
|
88
89
|
output = RayoNode.import parse_stanza(output).root
|
89
90
|
connection.expects(:write_to_stream).once.returns true
|
90
91
|
iq = Blather::Stanza::Iq.new :set, '9f00061@call.rayo.net'
|
@@ -106,9 +107,9 @@ module Punchblock
|
|
106
107
|
|
107
108
|
write_thread.join
|
108
109
|
|
109
|
-
output.state_name.should == :executing
|
110
|
+
output.state_name.should be == :executing
|
110
111
|
|
111
|
-
connection.original_component_from_id('fgh4590').should == output
|
112
|
+
connection.original_component_from_id('fgh4590').should be == output
|
112
113
|
|
113
114
|
example_complete = import_stanza <<-MSG
|
114
115
|
<presence to='16577@app.rayo.net/1' from='9f00061@call.rayo.net/fgh4590'>
|
@@ -119,17 +120,17 @@ module Punchblock
|
|
119
120
|
MSG
|
120
121
|
|
121
122
|
connection.__send__ :handle_presence, example_complete
|
122
|
-
output.complete_event(0.5).source.should == output
|
123
|
+
output.complete_event(0.5).source.should be == output
|
123
124
|
|
124
|
-
output.component_id.should == 'fgh4590'
|
125
|
+
output.component_id.should be == 'fgh4590'
|
125
126
|
end
|
126
127
|
|
127
128
|
it 'should send a "Chat" presence when ready' do
|
128
129
|
client = connection.send :client
|
129
130
|
client.expects(:write).once.with do |stanza|
|
130
|
-
stanza.to.should == 'rayo.net'
|
131
|
-
|
132
|
-
|
131
|
+
stanza.to.should be == 'rayo.net'
|
132
|
+
stanza.should be_a Blather::Stanza::Presence::Status
|
133
|
+
stanza.chat?.should be true
|
133
134
|
end
|
134
135
|
connection.ready!
|
135
136
|
end
|
@@ -137,9 +138,9 @@ module Punchblock
|
|
137
138
|
it 'should send a "Do Not Disturb" presence when not_ready' do
|
138
139
|
client = connection.send :client
|
139
140
|
client.expects(:write).once.with do |stanza|
|
140
|
-
stanza.to.should == 'rayo.net'
|
141
|
-
|
142
|
-
|
141
|
+
stanza.to.should be == 'rayo.net'
|
142
|
+
stanza.should be_a Blather::Stanza::Presence::Status
|
143
|
+
stanza.dnd?.should be true
|
143
144
|
end
|
144
145
|
connection.not_ready!
|
145
146
|
end
|
@@ -181,8 +182,8 @@ module Punchblock
|
|
181
182
|
it 'should call the event handler with the event' do
|
182
183
|
mock_event_handler.expects(:call).once.with do |event|
|
183
184
|
event.should be_instance_of Event::Offer
|
184
|
-
event.call_id.should == '9f00061'
|
185
|
-
event.domain.should == 'call.rayo.net'
|
185
|
+
event.call_id.should be == '9f00061'
|
186
|
+
event.domain.should be == 'call.rayo.net'
|
186
187
|
end
|
187
188
|
handle_presence
|
188
189
|
end
|
@@ -190,7 +191,7 @@ module Punchblock
|
|
190
191
|
it "should populate the call map with the domain for the call ID" do
|
191
192
|
handle_presence
|
192
193
|
callmap = connection.instance_variable_get(:'@callmap')
|
193
|
-
callmap['9f00061'].should == 'call.rayo.net'
|
194
|
+
callmap['9f00061'].should be == 'call.rayo.net'
|
194
195
|
end
|
195
196
|
end
|
196
197
|
|
@@ -238,10 +239,10 @@ module Punchblock
|
|
238
239
|
|
239
240
|
subject { cmd.response }
|
240
241
|
|
241
|
-
its(:call_id) { should == call_id }
|
242
|
-
its(:component_id) { should == component_id }
|
243
|
-
its(:name) { should == :item_not_found }
|
244
|
-
its(:text) { should == 'Could not find call [id=f6d437f4-1e18-457b-99f8-b5d853f50347]' }
|
242
|
+
its(:call_id) { should be == call_id }
|
243
|
+
its(:component_id) { should be == component_id }
|
244
|
+
its(:name) { should be == :item_not_found }
|
245
|
+
its(:text) { should be == 'Could not find call [id=f6d437f4-1e18-457b-99f8-b5d853f50347]' }
|
245
246
|
end
|
246
247
|
|
247
248
|
describe "#prep_command_for_execution" do
|
@@ -253,7 +254,7 @@ module Punchblock
|
|
253
254
|
|
254
255
|
it "should use the correct JID" do
|
255
256
|
stanza = subject.prep_command_for_execution command
|
256
|
-
stanza.to.should == expected_jid
|
257
|
+
stanza.to.should be == expected_jid
|
257
258
|
end
|
258
259
|
end
|
259
260
|
|
@@ -262,7 +263,7 @@ module Punchblock
|
|
262
263
|
let(:expected_jid) { 'abc123@calls.rayo.net' }
|
263
264
|
|
264
265
|
it "should use the correct JID" do
|
265
|
-
stanza.to.should == expected_jid
|
266
|
+
stanza.to.should be == expected_jid
|
266
267
|
end
|
267
268
|
end
|
268
269
|
|
@@ -271,7 +272,7 @@ module Punchblock
|
|
271
272
|
let(:expected_jid) { 'abc123@calls.rayo.net' }
|
272
273
|
|
273
274
|
it "should use the correct JID" do
|
274
|
-
stanza.to.should == expected_jid
|
275
|
+
stanza.to.should be == expected_jid
|
275
276
|
end
|
276
277
|
end
|
277
278
|
|
@@ -280,7 +281,7 @@ module Punchblock
|
|
280
281
|
let(:expected_jid) { 'abc123@calls.rayo.net/foobar' }
|
281
282
|
|
282
283
|
it "should use the correct JID" do
|
283
|
-
stanza.to.should == expected_jid
|
284
|
+
stanza.to.should be == expected_jid
|
284
285
|
end
|
285
286
|
end
|
286
287
|
|
@@ -289,7 +290,7 @@ module Punchblock
|
|
289
290
|
let(:expected_jid) { 'abc123@mixers.rayo.net' }
|
290
291
|
|
291
292
|
it "should use the correct JID" do
|
292
|
-
stanza.to.should == expected_jid
|
293
|
+
stanza.to.should be == expected_jid
|
293
294
|
end
|
294
295
|
end
|
295
296
|
|
@@ -298,7 +299,7 @@ module Punchblock
|
|
298
299
|
let(:expected_jid) { 'abc123@mixers.rayo.net/foobar' }
|
299
300
|
|
300
301
|
it "should use the correct JID" do
|
301
|
-
stanza.to.should == expected_jid
|
302
|
+
stanza.to.should be == expected_jid
|
302
303
|
end
|
303
304
|
end
|
304
305
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
4
6
|
class Event
|
5
7
|
describe Answered do
|
6
8
|
it 'registers itself' do
|
7
|
-
RayoNode.class_from_registration(:answered, 'urn:xmpp:rayo:1').should == Answered
|
9
|
+
RayoNode.class_from_registration(:answered, 'urn:xmpp:rayo:1').should be == Answered
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "from a stanza" do
|
@@ -25,7 +27,7 @@ module Punchblock
|
|
25
27
|
it_should_behave_like 'event'
|
26
28
|
it_should_behave_like 'event_headers'
|
27
29
|
|
28
|
-
its(:xmlns) { should == 'urn:xmpp:rayo:1' }
|
30
|
+
its(:xmlns) { should be == 'urn:xmpp:rayo:1' }
|
29
31
|
end
|
30
32
|
|
31
33
|
describe "when setting options in initializer" do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
@@ -6,7 +8,7 @@ module Punchblock
|
|
6
8
|
module AMI
|
7
9
|
describe Event do
|
8
10
|
it 'registers itself' do
|
9
|
-
RayoNode.class_from_registration(:event, 'urn:xmpp:rayo:asterisk:ami:1').should == Event
|
11
|
+
RayoNode.class_from_registration(:event, 'urn:xmpp:rayo:asterisk:ami:1').should be == Event
|
10
12
|
end
|
11
13
|
|
12
14
|
describe "from a stanza" do
|
@@ -27,9 +29,9 @@ module Punchblock
|
|
27
29
|
|
28
30
|
it_should_behave_like 'event'
|
29
31
|
|
30
|
-
its(:name) { should == 'Newchannel' }
|
31
|
-
its(:attributes) { should == [Event::Attribute.new(:channel, 'SIP/101-3f3f'), Event::Attribute.new(:state, 'Ring'), Event::Attribute.new(:callerid, '101'), Event::Attribute.new(:uniqueid, '1094154427.10')]}
|
32
|
-
its(:attributes_hash) { should == {:channel => 'SIP/101-3f3f', :state => 'Ring', :callerid => '101', :uniqueid => '1094154427.10'} }
|
32
|
+
its(:name) { should be == 'Newchannel' }
|
33
|
+
its(:attributes) { should be == [Event::Attribute.new(:channel, 'SIP/101-3f3f'), Event::Attribute.new(:state, 'Ring'), Event::Attribute.new(:callerid, '101'), Event::Attribute.new(:uniqueid, '1094154427.10')]}
|
34
|
+
its(:attributes_hash) { should be == {:channel => 'SIP/101-3f3f', :state => 'Ring', :callerid => '101', :uniqueid => '1094154427.10'} }
|
33
35
|
end
|
34
36
|
|
35
37
|
describe "when setting options in initializer" do
|
@@ -41,9 +43,9 @@ module Punchblock
|
|
41
43
|
:uniqueid => '1094154427.10'}
|
42
44
|
end
|
43
45
|
|
44
|
-
its(:name) { should == 'Newchannel' }
|
45
|
-
its(:attributes) { should == [Event::Attribute.new(:channel, 'SIP/101-3f3f'), Event::Attribute.new(:state, 'Ring'), Event::Attribute.new(:callerid, '101'), Event::Attribute.new(:uniqueid, '1094154427.10')]}
|
46
|
-
its(:attributes_hash) { should == {:channel => 'SIP/101-3f3f', :state => 'Ring', :callerid => '101', :uniqueid => '1094154427.10'} }
|
46
|
+
its(:name) { should be == 'Newchannel' }
|
47
|
+
its(:attributes) { should be == [Event::Attribute.new(:channel, 'SIP/101-3f3f'), Event::Attribute.new(:state, 'Ring'), Event::Attribute.new(:callerid, '101'), Event::Attribute.new(:uniqueid, '1094154427.10')]}
|
48
|
+
its(:attributes_hash) { should be == {:channel => 'SIP/101-3f3f', :state => 'Ring', :callerid => '101', :uniqueid => '1094154427.10'} }
|
47
49
|
end
|
48
50
|
|
49
51
|
class Event
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
4
6
|
class Event
|
5
7
|
describe Complete do
|
6
8
|
it 'registers itself' do
|
7
|
-
RayoNode.class_from_registration(:complete, 'urn:xmpp:rayo:ext:1').should == Complete
|
9
|
+
RayoNode.class_from_registration(:complete, 'urn:xmpp:rayo:ext:1').should be == Complete
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "comparing for equality" do
|
@@ -30,7 +32,7 @@ module Punchblock
|
|
30
32
|
let(:component_id) { 'abcd' }
|
31
33
|
|
32
34
|
it "should be equal" do
|
33
|
-
subject.should == other_complete
|
35
|
+
subject.should be == other_complete
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
@@ -40,7 +42,7 @@ module Punchblock
|
|
40
42
|
let(:component_id) { 'abcd' }
|
41
43
|
|
42
44
|
it "should not be equal" do
|
43
|
-
subject.should_not == other_complete
|
45
|
+
subject.should_not be == other_complete
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
@@ -50,7 +52,7 @@ module Punchblock
|
|
50
52
|
let(:component_id) { 'abcd' }
|
51
53
|
|
52
54
|
it "should not be equal" do
|
53
|
-
subject.should_not == other_complete
|
55
|
+
subject.should_not be == other_complete
|
54
56
|
end
|
55
57
|
end
|
56
58
|
|
@@ -60,7 +62,7 @@ module Punchblock
|
|
60
62
|
let(:component_id) { 'efgh' }
|
61
63
|
|
62
64
|
it "should not be equal" do
|
63
|
-
subject.should_not == other_complete
|
65
|
+
subject.should_not be == other_complete
|
64
66
|
end
|
65
67
|
end
|
66
68
|
end
|
@@ -97,7 +99,7 @@ module Punchblock
|
|
97
99
|
|
98
100
|
it { should be_instance_of Complete::Stop }
|
99
101
|
|
100
|
-
its(:name) { should == :stop }
|
102
|
+
its(:name) { should be == :stop }
|
101
103
|
end
|
102
104
|
|
103
105
|
describe Complete::Hangup do
|
@@ -113,7 +115,7 @@ module Punchblock
|
|
113
115
|
|
114
116
|
it { should be_instance_of Complete::Hangup }
|
115
117
|
|
116
|
-
its(:name) { should == :hangup }
|
118
|
+
its(:name) { should be == :hangup }
|
117
119
|
end
|
118
120
|
|
119
121
|
describe Complete::Error do
|
@@ -131,15 +133,15 @@ module Punchblock
|
|
131
133
|
|
132
134
|
it { should be_instance_of Complete::Error }
|
133
135
|
|
134
|
-
its(:name) { should == :error }
|
135
|
-
its(:details) { should == "Something really bad happened" }
|
136
|
+
its(:name) { should be == :error }
|
137
|
+
its(:details) { should be == "Something really bad happened" }
|
136
138
|
|
137
139
|
describe "when setting options in initializer" do
|
138
140
|
subject do
|
139
141
|
Complete::Error.new :details => 'Ooops'
|
140
142
|
end
|
141
143
|
|
142
|
-
its(:details) { should == 'Ooops' }
|
144
|
+
its(:details) { should be == 'Ooops' }
|
143
145
|
end
|
144
146
|
end
|
145
147
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
4
6
|
class Event
|
5
7
|
describe DTMF do
|
6
8
|
it 'registers itself' do
|
7
|
-
RayoNode.class_from_registration(:dtmf, 'urn:xmpp:rayo:1').should == DTMF
|
9
|
+
RayoNode.class_from_registration(:dtmf, 'urn:xmpp:rayo:1').should be == DTMF
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "from a stanza" do
|
@@ -16,8 +18,8 @@ module Punchblock
|
|
16
18
|
|
17
19
|
it_should_behave_like 'event'
|
18
20
|
|
19
|
-
its(:signal) { should == '#' }
|
20
|
-
its(:xmlns) { should == 'urn:xmpp:rayo:1' }
|
21
|
+
its(:signal) { should be == '#' }
|
22
|
+
its(:xmlns) { should be == 'urn:xmpp:rayo:1' }
|
21
23
|
end
|
22
24
|
|
23
25
|
describe "when setting options in initializer" do
|
@@ -25,7 +27,7 @@ module Punchblock
|
|
25
27
|
DTMF.new :signal => '#'
|
26
28
|
end
|
27
29
|
|
28
|
-
its(:signal) { should == '#' }
|
30
|
+
its(:signal) { should be == '#' }
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
4
6
|
class Event
|
5
7
|
describe End do
|
6
8
|
it 'registers itself' do
|
7
|
-
RayoNode.class_from_registration(:end, 'urn:xmpp:rayo:1').should == End
|
9
|
+
RayoNode.class_from_registration(:end, 'urn:xmpp:rayo:1').should be == End
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "from a stanza" do
|
@@ -26,8 +28,8 @@ module Punchblock
|
|
26
28
|
it_should_behave_like 'event'
|
27
29
|
it_should_behave_like 'event_headers'
|
28
30
|
|
29
|
-
its(:reason) { should == :timeout }
|
30
|
-
its(:xmlns) { should == 'urn:xmpp:rayo:1' }
|
31
|
+
its(:reason) { should be == :timeout }
|
32
|
+
its(:xmlns) { should be == 'urn:xmpp:rayo:1' }
|
31
33
|
end
|
32
34
|
|
33
35
|
describe "when setting options in initializer" do
|
@@ -36,7 +38,7 @@ module Punchblock
|
|
36
38
|
:headers => { :x_skill => "agent", :x_customer_id => "8877" }
|
37
39
|
end
|
38
40
|
|
39
|
-
its(:reason) { should == :hangup }
|
41
|
+
its(:reason) { should be == :hangup }
|
40
42
|
it_should_behave_like 'event_headers'
|
41
43
|
end
|
42
44
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
4
6
|
class Event
|
5
7
|
describe Joined do
|
6
8
|
it 'registers itself' do
|
7
|
-
RayoNode.class_from_registration(:joined, 'urn:xmpp:rayo:1').should == Joined
|
9
|
+
RayoNode.class_from_registration(:joined, 'urn:xmpp:rayo:1').should be == Joined
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "from a stanza" do
|
@@ -16,16 +18,16 @@ module Punchblock
|
|
16
18
|
|
17
19
|
it_should_behave_like 'event'
|
18
20
|
|
19
|
-
its(:other_call_id) { should == 'b' }
|
20
|
-
its(:mixer_name) { should == 'm' }
|
21
|
-
its(:xmlns) { should == 'urn:xmpp:rayo:1' }
|
21
|
+
its(:other_call_id) { should be == 'b' }
|
22
|
+
its(:mixer_name) { should be == 'm' }
|
23
|
+
its(:xmlns) { should be == 'urn:xmpp:rayo:1' }
|
22
24
|
end
|
23
25
|
|
24
26
|
describe "when setting options in initializer" do
|
25
27
|
subject { Joined.new :other_call_id => 'abc123', :mixer_name => 'blah' }
|
26
28
|
|
27
|
-
its(:other_call_id) { should == 'abc123' }
|
28
|
-
its(:mixer_name) { should == 'blah' }
|
29
|
+
its(:other_call_id) { should be == 'abc123' }
|
30
|
+
its(:mixer_name) { should be == 'blah' }
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
4
6
|
class Event
|
5
7
|
describe Offer do
|
6
8
|
it 'registers itself' do
|
7
|
-
RayoNode.class_from_registration(:offer, 'urn:xmpp:rayo:1').should == Offer
|
9
|
+
RayoNode.class_from_registration(:offer, 'urn:xmpp:rayo:1').should be == Offer
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "from a stanza" do
|
@@ -27,8 +29,8 @@ module Punchblock
|
|
27
29
|
it_should_behave_like 'event'
|
28
30
|
it_should_behave_like 'event_headers'
|
29
31
|
|
30
|
-
its(:to) { should == 'tel:+18003211212' }
|
31
|
-
its(:from) { should == 'tel:+13058881212' }
|
32
|
+
its(:to) { should be == 'tel:+18003211212' }
|
33
|
+
its(:from) { should be == 'tel:+13058881212' }
|
32
34
|
end
|
33
35
|
|
34
36
|
describe "when setting options in initializer" do
|
@@ -40,8 +42,8 @@ module Punchblock
|
|
40
42
|
|
41
43
|
it_should_behave_like 'event_headers'
|
42
44
|
|
43
|
-
its(:to) { should == 'tel:+18003211212' }
|
44
|
-
its(:from) { should == 'tel:+13058881212' }
|
45
|
+
its(:to) { should be == 'tel:+18003211212' }
|
46
|
+
its(:from) { should be == 'tel:+13058881212' }
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
4
6
|
class Event
|
5
7
|
describe Ringing do
|
6
8
|
it 'registers itself' do
|
7
|
-
RayoNode.class_from_registration(:ringing, 'urn:xmpp:rayo:1').should == Ringing
|
9
|
+
RayoNode.class_from_registration(:ringing, 'urn:xmpp:rayo:1').should be == Ringing
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "from a stanza" do
|
@@ -25,7 +27,7 @@ module Punchblock
|
|
25
27
|
it_should_behave_like 'event'
|
26
28
|
it_should_behave_like 'event_headers'
|
27
29
|
|
28
|
-
its(:xmlns) { should == 'urn:xmpp:rayo:1' }
|
30
|
+
its(:xmlns) { should be == 'urn:xmpp:rayo:1' }
|
29
31
|
end
|
30
32
|
|
31
33
|
describe "when setting options in initializer" do
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
4
6
|
class Event
|
5
7
|
describe Unjoined do
|
6
8
|
it 'registers itself' do
|
7
|
-
RayoNode.class_from_registration(:unjoined, 'urn:xmpp:rayo:1').should == Unjoined
|
9
|
+
RayoNode.class_from_registration(:unjoined, 'urn:xmpp:rayo:1').should be == Unjoined
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "from a stanza" do
|
@@ -16,16 +18,16 @@ module Punchblock
|
|
16
18
|
|
17
19
|
it_should_behave_like 'event'
|
18
20
|
|
19
|
-
its(:other_call_id) { should == 'b' }
|
20
|
-
its(:mixer_name) { should == 'm' }
|
21
|
-
its(:xmlns) { should == 'urn:xmpp:rayo:1' }
|
21
|
+
its(:other_call_id) { should be == 'b' }
|
22
|
+
its(:mixer_name) { should be == 'm' }
|
23
|
+
its(:xmlns) { should be == 'urn:xmpp:rayo:1' }
|
22
24
|
end
|
23
25
|
|
24
26
|
describe "when setting options in initializer" do
|
25
27
|
subject { Unjoined.new :other_call_id => 'abc123', :mixer_name => 'blah' }
|
26
28
|
|
27
|
-
its(:other_call_id) { should == 'abc123' }
|
28
|
-
its(:mixer_name) { should == 'blah' }
|
29
|
+
its(:other_call_id) { should be == 'abc123' }
|
30
|
+
its(:mixer_name) { should be == 'blah' }
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Punchblock
|
@@ -5,40 +7,40 @@ module Punchblock
|
|
5
7
|
it 'will auto-inherit nodes' do
|
6
8
|
n = parse_stanza "<header name='boo' value='bah' />"
|
7
9
|
h = Header.new n.root
|
8
|
-
h.name.should == :boo
|
9
|
-
h.value.should == 'bah'
|
10
|
+
h.name.should be == :boo
|
11
|
+
h.value.should be == 'bah'
|
10
12
|
end
|
11
13
|
|
12
14
|
it 'has a name attribute' do
|
13
15
|
n = Header.new :boo, 'bah'
|
14
|
-
n.name.should == :boo
|
16
|
+
n.name.should be == :boo
|
15
17
|
n.name = :foo
|
16
|
-
n.name.should == :foo
|
18
|
+
n.name.should be == :foo
|
17
19
|
end
|
18
20
|
|
19
21
|
it "substitutes - for _ on the name attribute when reading" do
|
20
22
|
n = parse_stanza "<header name='boo-bah' value='foo' />"
|
21
23
|
h = Header.new n.root
|
22
|
-
h.name.should == :boo_bah
|
24
|
+
h.name.should be == :boo_bah
|
23
25
|
end
|
24
26
|
|
25
27
|
it "substitutes _ for - on the name attribute when writing" do
|
26
28
|
h = Header.new :boo_bah, 'foo'
|
27
|
-
h.to_xml.should == '<header name="boo-bah" value="foo"/>'
|
29
|
+
h.to_xml.should be == '<header name="boo-bah" value="foo"/>'
|
28
30
|
end
|
29
31
|
|
30
32
|
it 'has a value attribute' do
|
31
33
|
n = Header.new :boo, 'en'
|
32
|
-
n.value.should == 'en'
|
34
|
+
n.value.should be == 'en'
|
33
35
|
n.value = 'de'
|
34
|
-
n.value.should == 'de'
|
36
|
+
n.value.should be == 'de'
|
35
37
|
end
|
36
38
|
|
37
39
|
it 'can determine equality' do
|
38
40
|
a = Header.new :boo, 'bah'
|
39
|
-
a.should == Header.new(:boo, 'bah')
|
40
|
-
a.should_not == Header.new(:bah, 'bah')
|
41
|
-
a.should_not == Header.new(:boo, 'boo')
|
41
|
+
a.should be == Header.new(:boo, 'bah')
|
42
|
+
a.should_not be == Header.new(:bah, 'bah')
|
43
|
+
a.should_not be == Header.new(:boo, 'boo')
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end # Punchblock
|