adhearsion-asterisk 0.1.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 +10 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +6 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +143 -0
- data/Rakefile +23 -0
- data/adhearsion-asterisk.gemspec +35 -0
- data/lib/adhearsion-asterisk.rb +1 -0
- data/lib/adhearsion/asterisk.rb +12 -0
- data/lib/adhearsion/asterisk/config_generator.rb +103 -0
- data/lib/adhearsion/asterisk/config_generator/agents.rb +138 -0
- data/lib/adhearsion/asterisk/config_generator/queues.rb +247 -0
- data/lib/adhearsion/asterisk/config_generator/voicemail.rb +238 -0
- data/lib/adhearsion/asterisk/config_manager.rb +60 -0
- data/lib/adhearsion/asterisk/plugin.rb +464 -0
- data/lib/adhearsion/asterisk/queue_proxy.rb +177 -0
- data/lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb +81 -0
- data/lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb +132 -0
- data/lib/adhearsion/asterisk/version.rb +5 -0
- data/spec/adhearsion/asterisk/config_generators/agents_spec.rb +258 -0
- data/spec/adhearsion/asterisk/config_generators/queues_spec.rb +322 -0
- data/spec/adhearsion/asterisk/config_generators/voicemail_spec.rb +306 -0
- data/spec/adhearsion/asterisk/config_manager_spec.rb +125 -0
- data/spec/adhearsion/asterisk/plugin_spec.rb +618 -0
- data/spec/adhearsion/asterisk/queue_proxy/agent_proxy_spec.rb +90 -0
- data/spec/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy_spec.rb +145 -0
- data/spec/adhearsion/asterisk/queue_proxy_spec.rb +156 -0
- data/spec/adhearsion/asterisk_spec.rb +9 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/the_following_code.rb +3 -0
- metadata +229 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Adhearsion::Asterisk
|
4
|
+
class QueueProxy
|
5
|
+
describe AgentProxy do
|
6
|
+
let(:queue_name) { 'foobar' }
|
7
|
+
let(:mock_ee) { mock 'Adhearsion::DialPlan::ExecutionEnvironment' }
|
8
|
+
let(:mock_queue) { stub_everything 'QueueProxy', :environment => mock_ee, :name => queue_name }
|
9
|
+
|
10
|
+
let(:agent_id) { 123 }
|
11
|
+
|
12
|
+
subject { AgentProxy.new("Agent/#{agent_id}", mock_queue) }
|
13
|
+
|
14
|
+
it 'should properly retrieve metadata' do
|
15
|
+
metadata_name = 'status'
|
16
|
+
mock_ee.expects(:variable).once.with("AGENT(#{agent_id}:#{metadata_name})")
|
17
|
+
subject.send :agent_metadata, metadata_name
|
18
|
+
end
|
19
|
+
|
20
|
+
it '#logged_in? should return true if the "state" of an agent == LOGGEDIN' do
|
21
|
+
subject.expects(:agent_metadata).once.with('status').returns 'LOGGEDIN'
|
22
|
+
subject.logged_in?.should be true
|
23
|
+
|
24
|
+
subject.expects(:agent_metadata).once.with('status').returns 'LOGGEDOUT'
|
25
|
+
subject.logged_in?.should_not be true
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'the AgentProxy should populate its own "id" property to the numerical ID of the "interface" with which it was constructed' do
|
29
|
+
id = '123'
|
30
|
+
AgentProxy.new("Agent/#{id}", mock_queue).id.should == id
|
31
|
+
AgentProxy.new(id, mock_queue).id.should == id
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should pause an agent properly from a certain queue' do
|
35
|
+
mock_ee.expects(:get_variable).once.with("PQMSTATUS").returns "PAUSED"
|
36
|
+
mock_ee.expects(:execute).once.with("PauseQueueMember", queue_name, "Agent/#{agent_id}")
|
37
|
+
|
38
|
+
subject.pause!.should be true
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should pause an agent properly from a certain queue and return false when the agent did not exist' do
|
42
|
+
mock_ee.expects(:get_variable).once.with("PQMSTATUS").returns "NOTFOUND"
|
43
|
+
mock_ee.expects(:execute).once.with("PauseQueueMember", queue_name, "Agent/#{agent_id}")
|
44
|
+
|
45
|
+
subject.pause!.should be false
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should pause an agent globally properly' do
|
49
|
+
mock_ee.expects(:get_variable).once.with("PQMSTATUS").returns "PAUSED"
|
50
|
+
mock_ee.expects(:execute).once.with "PauseQueueMember", nil, "Agent/#{agent_id}"
|
51
|
+
|
52
|
+
subject.pause! :everywhere => true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should unpause an agent properly' do
|
56
|
+
mock_ee.expects(:get_variable).once.with("UPQMSTATUS").returns "UNPAUSED"
|
57
|
+
mock_ee.expects(:execute).once.with("UnpauseQueueMember", queue_name, "Agent/#{agent_id}")
|
58
|
+
|
59
|
+
subject.unpause!.should be true
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should unpause an agent globally properly' do
|
63
|
+
mock_ee.expects(:get_variable).once.with("UPQMSTATUS").returns "UNPAUSED"
|
64
|
+
mock_ee.expects(:execute).once.with("UnpauseQueueMember", nil, "Agent/#{agent_id}")
|
65
|
+
|
66
|
+
subject.unpause!(:everywhere => true).should be true
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should remove an agent properly' do
|
70
|
+
mock_ee.expects(:execute).once.with('RemoveQueueMember', queue_name, "Agent/#{agent_id}")
|
71
|
+
mock_ee.expects(:get_variable).once.with("RQMSTATUS").returns "REMOVED"
|
72
|
+
subject.remove!.should be true
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should remove an agent properly' do
|
76
|
+
mock_ee.expects(:execute).once.with('RemoveQueueMember', queue_name, "Agent/#{agent_id}")
|
77
|
+
mock_ee.expects(:get_variable).once.with("RQMSTATUS").returns "NOTINQUEUE"
|
78
|
+
subject.remove!.should be false
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should raise a QueueDoesNotExistError when removing an agent from a queue that doesn't exist" do
|
82
|
+
mock_ee.expects(:execute).once.with("RemoveQueueMember", queue_name, "Agent/#{agent_id}")
|
83
|
+
mock_ee.expects(:get_variable).once.with("RQMSTATUS").returns "NOSUCHQUEUE"
|
84
|
+
lambda {
|
85
|
+
subject.remove!
|
86
|
+
}.should raise_error QueueDoesNotExistError
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Adhearsion::Asterisk
|
4
|
+
class QueueProxy
|
5
|
+
describe QueueAgentsListProxy do
|
6
|
+
let(:queue_name) { 'foobar' }
|
7
|
+
let(:agent_channel) { "Agent/123" }
|
8
|
+
let(:mock_ee) { mock 'Adhearsion::DialPlan::ExecutionEnvironment' }
|
9
|
+
let(:mock_queue) { stub_everything 'QueueProxy', :environment => mock_ee, :name => queue_name }
|
10
|
+
|
11
|
+
subject { QueueAgentsListProxy.new mock_queue, true }
|
12
|
+
|
13
|
+
it 'should fetch the members with the queue name' do
|
14
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_COUNT(#{queue_name})").returns 5
|
15
|
+
subject.size.should == 5
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should not fetch a QUEUE_MEMBER_COUNT each time #count is called when caching is enabled' do
|
19
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_COUNT(#{queue_name})").returns 0
|
20
|
+
10.times { subject.size }
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'when fetching agents, it should properly split by the supported delimiters' do
|
24
|
+
mock_ee.expects(:get_variable).with("QUEUE_MEMBER_LIST(#{queue_name})").returns('Agent/007,Agent/003,Zap/2')
|
25
|
+
subject.to_a.size.should == 3
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'when fetching agents, each array index should be an instance of AgentProxy' do
|
29
|
+
mock_ee.expects(:get_variable).with("QUEUE_MEMBER_LIST(#{queue_name})").returns('Agent/007,Agent/003,Zap/2')
|
30
|
+
agents = subject.to_a
|
31
|
+
agents.size.should > 0
|
32
|
+
agents.each do |agent|
|
33
|
+
agent.should be_a AgentProxy
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it '#<< should new the channel driver given as the argument to the system' do
|
38
|
+
mock_ee.expects(:execute).once.with("AddQueueMember", queue_name, agent_channel, "", "", "", "")
|
39
|
+
mock_ee.expects(:get_variable).once.with('AQMSTATUS').returns('ADDED')
|
40
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").returns "Agent/007,SIP/2302,Local/2510@from-internal"
|
41
|
+
subject.new agent_channel
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'when a queue agent is dynamically added and the queue does not exist, a QueueDoesNotExistError should be raised' do
|
45
|
+
mock_ee.expects(:execute).once.with("AddQueueMember", queue_name, agent_channel, "", "", "", "")
|
46
|
+
mock_ee.expects(:get_variable).once.with('AQMSTATUS').returns('NOSUCHQUEUE')
|
47
|
+
lambda {
|
48
|
+
subject.new agent_channel
|
49
|
+
}.should raise_error QueueDoesNotExistError
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'when a queue agent is dynamiaclly added and the adding was successful, an AgentProxy should be returned' do
|
53
|
+
mock_ee.expects(:get_variable).once.with("AQMSTATUS").returns("ADDED")
|
54
|
+
mock_ee.expects(:execute).once.with("AddQueueMember", queue_name, agent_channel, "", "", "", "")
|
55
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").returns "Agent/007,SIP/2302,Local/2510@from-internal"
|
56
|
+
subject.new(agent_channel).should be_a AgentProxy
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'when a queue agent is dynamiaclly added and the adding was unsuccessful, a false should be returned' do
|
60
|
+
mock_ee.expects(:get_variable).once.with("AQMSTATUS").returns("MEMBERALREADY")
|
61
|
+
mock_ee.expects(:execute).once.with("AddQueueMember", queue_name, agent_channel, "", "", "", "")
|
62
|
+
subject.new(agent_channel).should be false
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should raise an argument when an unrecognized key is given to #new' do
|
66
|
+
lambda {
|
67
|
+
subject.new :foo => "bar"
|
68
|
+
}.should raise_error ArgumentError
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should execute AddQueueMember with the penalty properly' do
|
72
|
+
mock_ee.expects(:execute).once.with('AddQueueMember', queue_name, agent_channel, 10, '', '','')
|
73
|
+
mock_ee.expects(:get_variable).once.with('AQMSTATUS').returns('ADDED')
|
74
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").returns "Agent/007,SIP/2302,Local/2510@from-internal"
|
75
|
+
subject.new agent_channel, :penalty => 10
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should execute AddQueueMember with the state_interface properly' do
|
79
|
+
mock_ee.expects(:execute).once.with('AddQueueMember', queue_name, agent_channel, '', '', '','SIP/2302')
|
80
|
+
mock_ee.expects(:get_variable).once.with('AQMSTATUS').returns('ADDED')
|
81
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").returns "Agent/007,SIP/2302,Local/2510@from-internal"
|
82
|
+
subject.new agent_channel, :state_interface => 'SIP/2302'
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should execute AddQueueMember properly when the name is given' do
|
86
|
+
agent_name = 'Jay Phillips'
|
87
|
+
mock_ee.expects(:execute).once.with('AddQueueMember', queue_name, agent_channel, '', '', agent_name,'')
|
88
|
+
mock_ee.expects(:get_variable).once.with('AQMSTATUS').returns('ADDED')
|
89
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").returns "Agent/007,SIP/2302,Local/2510@from-internal"
|
90
|
+
subject.new agent_channel, :name => agent_name
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should execute AddQueueMember properly when the name, penalty, and interface is given' do
|
94
|
+
agent_name, penalty = 'Jay Phillips', 4
|
95
|
+
mock_ee.expects(:execute).once.with('AddQueueMember', queue_name, agent_channel, penalty, '', agent_name,'')
|
96
|
+
mock_ee.expects(:get_variable).once.with('AQMSTATUS').returns('ADDED')
|
97
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").returns "Agent/007,SIP/2302,Local/2510@from-internal"
|
98
|
+
subject.new agent_channel, :name => agent_name, :penalty => penalty
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should execute AddQueueMember properly when the name, penalty, interface, and state_interface is given' do
|
102
|
+
agent_name, penalty, state_interface = 'Jay Phillips', 4, 'SIP/2302'
|
103
|
+
mock_ee.expects(:execute).once.with('AddQueueMember', queue_name, agent_channel, penalty, '', agent_name, state_interface)
|
104
|
+
mock_ee.expects(:get_variable).once.with('AQMSTATUS').returns('ADDED')
|
105
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").returns "Agent/007,SIP/2302,Local/2510@from-internal"
|
106
|
+
subject.new agent_channel, :name => agent_name, :penalty => penalty, :state_interface => state_interface
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should log an agent in properly with no agent id given" do
|
110
|
+
mock_ee.expects(:execute).once.with('AgentLogin', nil, 's')
|
111
|
+
subject.login!
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should remove "Agent/" before the agent ID given if necessary when logging an agent in' do
|
115
|
+
mock_ee.expects(:execute).once.with('AgentLogin', '007', 's')
|
116
|
+
subject.login! 'Agent/007'
|
117
|
+
|
118
|
+
mock_ee.expects(:execute).once.with('AgentLogin', '007', 's')
|
119
|
+
subject.login! '007'
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should add an agent silently properly' do
|
123
|
+
mock_ee.expects(:execute).once.with('AgentLogin', '007', '')
|
124
|
+
subject.login! 'Agent/007', :silent => false
|
125
|
+
|
126
|
+
mock_ee.expects(:execute).once.with('AgentLogin', '008', 's')
|
127
|
+
subject.login! 'Agent/008', :silent => true
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'logging an agent in should raise an ArgumentError is unrecognized arguments are given' do
|
131
|
+
lambda {
|
132
|
+
subject.login! 1,2,3,4,5
|
133
|
+
}.should raise_error ArgumentError
|
134
|
+
|
135
|
+
lambda {
|
136
|
+
subject.login! 1337, :sssssilent => false
|
137
|
+
}.should raise_error ArgumentError
|
138
|
+
|
139
|
+
lambda {
|
140
|
+
subject.login! 777, 6,5,4,3,2,1, :wee => :wee
|
141
|
+
}.should raise_error ArgumentError
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Adhearsion::Asterisk
|
4
|
+
describe QueueProxy do
|
5
|
+
let(:queue_name) { 'foobar' }
|
6
|
+
let(:mock_ee) { mock 'Adhearsion::DialPlan::ExecutionEnvironment' }
|
7
|
+
|
8
|
+
subject { QueueProxy.new queue_name, mock_ee }
|
9
|
+
|
10
|
+
it "should respond to #join!, #agents" do
|
11
|
+
%w[join! agents].each do |method|
|
12
|
+
subject.should respond_to(method)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return a QueueAgentsListProxy when #agents is called' do
|
17
|
+
subject.agents.should be_a Adhearsion::Asterisk::QueueProxy::QueueAgentsListProxy
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#join' do
|
21
|
+
it 'should properly join a queue' do
|
22
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "", '', '', '', '')
|
23
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "FULL"
|
24
|
+
subject.join!
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return a symbol representing the result of joining the queue' do
|
28
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "", '', '', '', '')
|
29
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "TIMEOUT"
|
30
|
+
subject.join!.should be :timeout
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should return :completed after joining the queue and being connected' do
|
34
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "", '', '', '', '')
|
35
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns nil
|
36
|
+
subject.join!.should be :completed
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should join a queue with a timeout properly' do
|
40
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "", '', '', '60', '')
|
41
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
42
|
+
subject.join! :timeout => 1.minute
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should join a queue with an announcement file properly' do
|
46
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "", '', 'custom_announcement_file_here', '', '')
|
47
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
48
|
+
subject.join! :announce => 'custom_announcement_file_here'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should join a queue with an agi script properly' do
|
52
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, '', '', '', '','agi://localhost/queue_agi_test')
|
53
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINUNAVAIL"
|
54
|
+
subject.join! :agi => 'agi://localhost/queue_agi_test'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should join a queue with allow_transfer properly' do
|
58
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "Tt", '', '', '', '')
|
59
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
60
|
+
subject.join! :allow_transfer => :everyone
|
61
|
+
|
62
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "T", '', '', '', '')
|
63
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
64
|
+
subject.join! :allow_transfer => :caller
|
65
|
+
|
66
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "t", '', '', '', '')
|
67
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
68
|
+
subject.join! :allow_transfer => :agent
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should join a queue with allow_hangup properly' do
|
72
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "Hh", '', '', '', '')
|
73
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
74
|
+
subject.join! :allow_hangup => :everyone
|
75
|
+
|
76
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "H", '', '', '', '')
|
77
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
78
|
+
subject.join! :allow_hangup => :caller
|
79
|
+
|
80
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "h", '', '', '', '')
|
81
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
82
|
+
subject.join! :allow_hangup => :agent
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should join a queue properly with the :play argument' do
|
86
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "r", '', '', '', '')
|
87
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
88
|
+
subject.join! :play => :ringing
|
89
|
+
|
90
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "", '', '', '', '')
|
91
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
92
|
+
subject.join! :play => :music
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'joining a queue with many options specified' do
|
96
|
+
mock_ee.expects(:execute).once.with("queue", queue_name, "rtHh", '', '', '120', '')
|
97
|
+
mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
|
98
|
+
subject.join! :allow_transfer => :agent, :timeout => 2.minutes,
|
99
|
+
:play => :ringing, :allow_hangup => :everyone
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should raise an ArgumentError when unrecognized Hash key arguments are given' do
|
103
|
+
lambda {
|
104
|
+
subject.join! :misspelled => true
|
105
|
+
}.should raise_error ArgumentError
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'agents' do
|
110
|
+
it 'should raise an argument error with unrecognized key' do
|
111
|
+
lambda {
|
112
|
+
subject.agents(:cached => true) # common typo
|
113
|
+
}.should raise_error ArgumentError
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should return a correct boolean for #exists?' do
|
118
|
+
mock_ee.expects(:execute).once.with("RemoveQueueMember", queue_name, "SIP/AdhearsionQueueExistenceCheck")
|
119
|
+
mock_ee.expects(:get_variable).once.with("RQMSTATUS").returns "NOTINQUEUE"
|
120
|
+
subject.exists?.should be true
|
121
|
+
|
122
|
+
mock_ee.expects(:execute).once.with("RemoveQueueMember", queue_name, "SIP/AdhearsionQueueExistenceCheck")
|
123
|
+
mock_ee.expects(:get_variable).once.with("RQMSTATUS").returns "NOSUCHQUEUE"
|
124
|
+
subject.exists?.should be false
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'waiting_count for a queue that does exist' do
|
128
|
+
mock_ee.expects(:get_variable).once.with("QUEUE_WAITING_COUNT(#{queue_name})").returns "50"
|
129
|
+
subject.expects(:exists?).once.returns true
|
130
|
+
subject.waiting_count.should == 50
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'waiting_count for a queue that does not exist' do
|
134
|
+
lambda {
|
135
|
+
subject.expects(:exists?).once.returns false
|
136
|
+
subject.waiting_count
|
137
|
+
}.should raise_error Adhearsion::Asterisk::QueueProxy::QueueDoesNotExistError
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'empty? should call waiting_count' do
|
141
|
+
subject.expects(:waiting_count).once.returns 0
|
142
|
+
subject.empty?.should be true
|
143
|
+
|
144
|
+
subject.expects(:waiting_count).once.returns 99
|
145
|
+
subject.empty?.should_not be true
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'any? should call waiting_count' do
|
149
|
+
subject.expects(:waiting_count).once.returns 0
|
150
|
+
subject.any?.should be false
|
151
|
+
|
152
|
+
subject.expects(:waiting_count).once.returns 99
|
153
|
+
subject.any?.should be true
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'simplecov-rcov'
|
3
|
+
class SimpleCov::Formatter::MergedFormatter
|
4
|
+
def format(result)
|
5
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
6
|
+
SimpleCov::Formatter::RcovFormatter.new.format(result)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter "/vendor/"
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'adhearsion/asterisk'
|
15
|
+
require 'mocha'
|
16
|
+
|
17
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.mock_with :mocha
|
21
|
+
config.filter_run :focus => true
|
22
|
+
config.run_all_when_everything_filtered = true
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adhearsion-asterisk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ben Langfeld
|
9
|
+
- Taylor Carpenter
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-01-18 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
requirement: &2164466260 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.10
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2164466260
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: bundler
|
28
|
+
requirement: &2164465340 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2164465340
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
requirement: &2164463600 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.5.0
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2164463600
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: ci_reporter
|
50
|
+
requirement: &2164462940 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.6.3
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *2164462940
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: simplecov
|
61
|
+
requirement: &2164461680 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *2164461680
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: simplecov-rcov
|
72
|
+
requirement: &2164476520 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *2164476520
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: yard
|
83
|
+
requirement: &2164475600 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.6.0
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: *2164475600
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: rake
|
94
|
+
requirement: &2164474640 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
type: :development
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: *2164474640
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: mocha
|
105
|
+
requirement: &2164472880 !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: *2164472880
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: bones
|
116
|
+
requirement: &2164472020 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: *2164472020
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-rspec
|
127
|
+
requirement: &2164470920 !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: *2164470920
|
136
|
+
- !ruby/object:Gem::Dependency
|
137
|
+
name: ruby_gntp
|
138
|
+
requirement: &2164495740 !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: *2164495740
|
147
|
+
description: An Adhearsion Plugin providing Asterisk-specific dialplan methods, AMI
|
148
|
+
access, and access to Asterisk configuration
|
149
|
+
email:
|
150
|
+
- blangfeld@adhearsion.com
|
151
|
+
- taylor@codecafe.com
|
152
|
+
executables: []
|
153
|
+
extensions: []
|
154
|
+
extra_rdoc_files: []
|
155
|
+
files:
|
156
|
+
- .gitignore
|
157
|
+
- .rspec
|
158
|
+
- CHANGELOG.md
|
159
|
+
- Gemfile
|
160
|
+
- Guardfile
|
161
|
+
- LICENSE.txt
|
162
|
+
- README.md
|
163
|
+
- Rakefile
|
164
|
+
- adhearsion-asterisk.gemspec
|
165
|
+
- lib/adhearsion-asterisk.rb
|
166
|
+
- lib/adhearsion/asterisk.rb
|
167
|
+
- lib/adhearsion/asterisk/config_generator.rb
|
168
|
+
- lib/adhearsion/asterisk/config_generator/agents.rb
|
169
|
+
- lib/adhearsion/asterisk/config_generator/queues.rb
|
170
|
+
- lib/adhearsion/asterisk/config_generator/voicemail.rb
|
171
|
+
- lib/adhearsion/asterisk/config_manager.rb
|
172
|
+
- lib/adhearsion/asterisk/plugin.rb
|
173
|
+
- lib/adhearsion/asterisk/queue_proxy.rb
|
174
|
+
- lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb
|
175
|
+
- lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb
|
176
|
+
- lib/adhearsion/asterisk/version.rb
|
177
|
+
- spec/adhearsion/asterisk/config_generators/agents_spec.rb
|
178
|
+
- spec/adhearsion/asterisk/config_generators/queues_spec.rb
|
179
|
+
- spec/adhearsion/asterisk/config_generators/voicemail_spec.rb
|
180
|
+
- spec/adhearsion/asterisk/config_manager_spec.rb
|
181
|
+
- spec/adhearsion/asterisk/plugin_spec.rb
|
182
|
+
- spec/adhearsion/asterisk/queue_proxy/agent_proxy_spec.rb
|
183
|
+
- spec/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy_spec.rb
|
184
|
+
- spec/adhearsion/asterisk/queue_proxy_spec.rb
|
185
|
+
- spec/adhearsion/asterisk_spec.rb
|
186
|
+
- spec/spec_helper.rb
|
187
|
+
- spec/support/the_following_code.rb
|
188
|
+
homepage: http://adhearsion.com
|
189
|
+
licenses: []
|
190
|
+
post_install_message:
|
191
|
+
rdoc_options: []
|
192
|
+
require_paths:
|
193
|
+
- lib
|
194
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
+
none: false
|
196
|
+
requirements:
|
197
|
+
- - ! '>='
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
segments:
|
201
|
+
- 0
|
202
|
+
hash: -3838859481465007038
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
none: false
|
205
|
+
requirements:
|
206
|
+
- - ! '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
segments:
|
210
|
+
- 0
|
211
|
+
hash: -3838859481465007038
|
212
|
+
requirements: []
|
213
|
+
rubyforge_project: adhearsion-asterisk
|
214
|
+
rubygems_version: 1.8.10
|
215
|
+
signing_key:
|
216
|
+
specification_version: 3
|
217
|
+
summary: Asterisk specific features for Adhearsion
|
218
|
+
test_files:
|
219
|
+
- spec/adhearsion/asterisk/config_generators/agents_spec.rb
|
220
|
+
- spec/adhearsion/asterisk/config_generators/queues_spec.rb
|
221
|
+
- spec/adhearsion/asterisk/config_generators/voicemail_spec.rb
|
222
|
+
- spec/adhearsion/asterisk/config_manager_spec.rb
|
223
|
+
- spec/adhearsion/asterisk/plugin_spec.rb
|
224
|
+
- spec/adhearsion/asterisk/queue_proxy/agent_proxy_spec.rb
|
225
|
+
- spec/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy_spec.rb
|
226
|
+
- spec/adhearsion/asterisk/queue_proxy_spec.rb
|
227
|
+
- spec/adhearsion/asterisk_spec.rb
|
228
|
+
- spec/spec_helper.rb
|
229
|
+
- spec/support/the_following_code.rb
|