adhearsion-asterisk 1.3.1 → 1.4.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.
@@ -250,8 +250,8 @@ describe "AgentsConfigGeneratorTestHelper" do
250
250
 
251
251
  it "generated_config_has_pair() works properly with two pairs" do
252
252
  @agents = mock "A fake agents with just one pair"
253
- @agents.expects(:conf).twice.returns("[general]\n\nqaz=qwerty\nagent => 1,2,3")
254
-
253
+ @agents.should_receive(:conf).twice.and_return("[general]\n\nqaz=qwerty\nagent => 1,2,3")
254
+
255
255
  generated_config_has_pair(:qaz => "qwerty").should be true
256
256
  generated_config_has_pair(:foo => "bar").should be false
257
257
  end
@@ -135,8 +135,8 @@ describe "The private, helper methods in QueueDefinition" do
135
135
 
136
136
  it '#boolean should convert a boolean into "yes" or "no"' do
137
137
  mock_of_properties = mock "mock of the properties instance variable of a QueueDefinition"
138
- mock_of_properties.expects(:[]=).once.with("icanhascheezburger", "yes")
139
- queue.expects(:properties).returns mock_of_properties
138
+ mock_of_properties.should_receive(:[]=).once.with("icanhascheezburger", "yes")
139
+ queue.should_receive(:properties).and_return mock_of_properties
140
140
  queue.send(:boolean, "icanhascheezburger" => true)
141
141
  end
142
142
 
@@ -148,39 +148,39 @@ describe "The private, helper methods in QueueDefinition" do
148
148
 
149
149
  it '#int should coerce a String into a Numeric if possible' do
150
150
  mock_of_properties = mock "mock of the properties instance variable of a QueueDefinition"
151
- mock_of_properties.expects(:[]=).once.with("chimpanzee", 1337)
152
- queue.expects(:properties).returns mock_of_properties
151
+ mock_of_properties.should_receive(:[]=).once.with("chimpanzee", 1337)
152
+ queue.should_receive(:properties).and_return mock_of_properties
153
153
  queue.send(:int, "chimpanzee" => "1337")
154
154
  end
155
155
 
156
156
  it '#string should add the argument directly to the properties' do
157
157
  mock_of_properties = mock "mock of the properties instance variable of a QueueDefinition"
158
- mock_of_properties.expects(:[]=).once.with("eins", "zwei")
159
- queue.expects(:properties).returns mock_of_properties
158
+ mock_of_properties.should_receive(:[]=).once.with("eins", "zwei")
159
+ queue.should_receive(:properties).and_return mock_of_properties
160
160
  queue.send(:string, "eins" => "zwei")
161
161
  end
162
162
 
163
163
  it '#one_of() should add its successful match to the properties attribute' do
164
164
  mock_properties = mock "mock of the properties instance variable of a QueueDefinition"
165
- mock_properties.expects(:[]=).once.with(:doesnt_matter, 5)
166
- queue.expects(:properties).once.returns mock_properties
165
+ mock_properties.should_receive(:[]=).once.with(:doesnt_matter, 5)
166
+ queue.should_receive(:properties).once.and_return mock_properties
167
167
  queue.send(:one_of, 1..100, :doesnt_matter => 5)
168
168
  end
169
169
 
170
170
  it "one_of() should convert booleans to yes/no" do
171
171
  mock_properties = mock "mock of the properties instance variable of a QueueDefinition"
172
- mock_properties.expects(:[]=).once.with(:doesnt_matter, 'yes')
173
- queue.expects(:properties).once.returns mock_properties
172
+ mock_properties.should_receive(:[]=).once.with(:doesnt_matter, 'yes')
173
+ queue.should_receive(:properties).once.and_return mock_properties
174
174
  queue.send(:one_of, [true, false, :strict], :doesnt_matter => true)
175
175
 
176
176
  mock_properties = mock "mock of the properties instance variable of a QueueDefinition"
177
- mock_properties.expects(:[]=).once.with(:doesnt_matter, :strict)
178
- queue.expects(:properties).once.returns mock_properties
177
+ mock_properties.should_receive(:[]=).once.with(:doesnt_matter, :strict)
178
+ queue.should_receive(:properties).once.and_return mock_properties
179
179
  queue.send(:one_of, [true, false, :strict], :doesnt_matter => :strict)
180
180
 
181
181
  mock_properties = mock "mock of the properties instance variable of a QueueDefinition"
182
- mock_properties.expects(:[]=).once.with(:doesnt_matter, 'no')
183
- queue.expects(:properties).once.returns mock_properties
182
+ mock_properties.should_receive(:[]=).once.with(:doesnt_matter, 'no')
183
+ queue.should_receive(:properties).once.and_return mock_properties
184
184
  queue.send(:one_of, [true, false, :strict], :doesnt_matter => false)
185
185
  end
186
186
 
@@ -315,7 +315,7 @@ describe "ConfigGeneratorTestHelper" do
315
315
  generated_config_has_pair(:foo => "bar").should be true
316
316
 
317
317
  @queues = mock "A fake queues with just one pair"
318
- @queues.expects(:to_s).twice.returns("[general]\n\nqaz=qwerty\nagent => 1,2,3")
318
+ @queues.should_receive(:to_s).twice.and_return("[general]\n\nqaz=qwerty\nagent => 1,2,3")
319
319
  generated_config_has_pair(:qaz => "qwerty").should be true
320
320
  generated_config_has_pair(:foo => "bar").should be false
321
321
  end
@@ -8,7 +8,7 @@ module ConfigurationManagerTestHelper
8
8
 
9
9
  def mock_config_manager_for(config_string)
10
10
  new_config_manager_with("bogus filename").tap do |manager|
11
- File.expects(:open).returns config_string
11
+ File.should_receive(:open).and_return config_string
12
12
  end
13
13
  end
14
14
 
@@ -4,7 +4,7 @@ module Adhearsion::Asterisk
4
4
  describe 'plugin loading' do
5
5
  before(:all) { Adhearsion::Plugin.init_plugins }
6
6
 
7
- let(:mock_call) { stub_everything 'Call' }
7
+ let(:mock_call) { mock(:call).as_null_object }
8
8
 
9
9
  it 'should extend Adhearsion::CallController with Asterisk methods' do
10
10
  Adhearsion::CallController.new(mock_call).should respond_to :play_time
@@ -5,7 +5,7 @@ module Adhearsion::Asterisk
5
5
  describe AgentProxy do
6
6
  let(:queue_name) { 'foobar' }
7
7
  let(:mock_ee) { mock 'Adhearsion::DialPlan::ExecutionEnvironment' }
8
- let(:mock_queue) { stub_everything 'QueueProxy', :environment => mock_ee, :name => queue_name }
8
+ let(:mock_queue) { mock('QueueProxy', :environment => mock_ee, :name => queue_name).as_null_object }
9
9
 
10
10
  let(:agent_id) { 123 }
11
11
 
@@ -13,15 +13,15 @@ module Adhearsion::Asterisk
13
13
 
14
14
  it 'should properly retrieve metadata' do
15
15
  metadata_name = 'status'
16
- mock_ee.expects(:variable).once.with("AGENT(#{agent_id}:#{metadata_name})")
16
+ mock_ee.should_receive(:variable).once.with("AGENT(#{agent_id}:#{metadata_name})")
17
17
  subject.send :agent_metadata, metadata_name
18
18
  end
19
19
 
20
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'
21
+ subject.should_receive(:agent_metadata).once.with('status').and_return 'LOGGEDIN'
22
22
  subject.logged_in?.should be true
23
23
 
24
- subject.expects(:agent_metadata).once.with('status').returns 'LOGGEDOUT'
24
+ subject.should_receive(:agent_metadata).once.with('status').and_return 'LOGGEDOUT'
25
25
  subject.logged_in?.should_not be true
26
26
  end
27
27
 
@@ -32,55 +32,55 @@ module Adhearsion::Asterisk
32
32
  end
33
33
 
34
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}")
35
+ mock_ee.should_receive(:get_variable).once.with("PQMSTATUS").and_return "PAUSED"
36
+ mock_ee.should_receive(:execute).once.with("PauseQueueMember", queue_name, "Agent/#{agent_id}")
37
37
 
38
38
  subject.pause!.should be true
39
39
  end
40
40
 
41
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}")
42
+ mock_ee.should_receive(:get_variable).once.with("PQMSTATUS").and_return "NOTFOUND"
43
+ mock_ee.should_receive(:execute).once.with("PauseQueueMember", queue_name, "Agent/#{agent_id}")
44
44
 
45
45
  subject.pause!.should be false
46
46
  end
47
47
 
48
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}"
49
+ mock_ee.should_receive(:get_variable).once.with("PQMSTATUS").and_return "PAUSED"
50
+ mock_ee.should_receive(:execute).once.with "PauseQueueMember", nil, "Agent/#{agent_id}"
51
51
 
52
52
  subject.pause! :everywhere => true
53
53
  end
54
54
 
55
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}")
56
+ mock_ee.should_receive(:get_variable).once.with("UPQMSTATUS").and_return "UNPAUSED"
57
+ mock_ee.should_receive(:execute).once.with("UnpauseQueueMember", queue_name, "Agent/#{agent_id}")
58
58
 
59
59
  subject.unpause!.should be true
60
60
  end
61
61
 
62
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}")
63
+ mock_ee.should_receive(:get_variable).once.with("UPQMSTATUS").and_return "UNPAUSED"
64
+ mock_ee.should_receive(:execute).once.with("UnpauseQueueMember", nil, "Agent/#{agent_id}")
65
65
 
66
66
  subject.unpause!(:everywhere => true).should be true
67
67
  end
68
68
 
69
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"
70
+ mock_ee.should_receive(:execute).once.with('RemoveQueueMember', queue_name, "Agent/#{agent_id}")
71
+ mock_ee.should_receive(:get_variable).once.with("RQMSTATUS").and_return "REMOVED"
72
72
  subject.remove!.should be true
73
73
  end
74
74
 
75
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"
76
+ mock_ee.should_receive(:execute).once.with('RemoveQueueMember', queue_name, "Agent/#{agent_id}")
77
+ mock_ee.should_receive(:get_variable).once.with("RQMSTATUS").and_return "NOTINQUEUE"
78
78
  subject.remove!.should be false
79
79
  end
80
80
 
81
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"
82
+ mock_ee.should_receive(:execute).once.with("RemoveQueueMember", queue_name, "Agent/#{agent_id}")
83
+ mock_ee.should_receive(:get_variable).once.with("RQMSTATUS").and_return "NOSUCHQUEUE"
84
84
  lambda {
85
85
  subject.remove!
86
86
  }.should raise_error QueueDoesNotExistError
@@ -6,27 +6,27 @@ module Adhearsion::Asterisk
6
6
  let(:queue_name) { 'foobar' }
7
7
  let(:agent_channel) { "Agent/123" }
8
8
  let(:mock_ee) { mock 'Adhearsion::DialPlan::ExecutionEnvironment' }
9
- let(:mock_queue) { stub_everything 'QueueProxy', :environment => mock_ee, :name => queue_name }
9
+ let(:mock_queue) { mock('QueueProxy', :environment => mock_ee, :name => queue_name).as_null_object }
10
10
 
11
11
  subject { QueueAgentsListProxy.new mock_queue, true }
12
12
 
13
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
14
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_COUNT(#{queue_name})").and_return 5
15
15
  subject.size.should == 5
16
16
  end
17
17
 
18
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
19
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_COUNT(#{queue_name})").and_return 0
20
20
  10.times { subject.size }
21
21
  end
22
22
 
23
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')
24
+ mock_ee.should_receive(:get_variable).with("QUEUE_MEMBER_LIST(#{queue_name})").and_return('Agent/007,Agent/003,Zap/2')
25
25
  subject.to_a.size.should == 3
26
26
  end
27
27
 
28
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')
29
+ mock_ee.should_receive(:get_variable).with("QUEUE_MEMBER_LIST(#{queue_name})").and_return('Agent/007,Agent/003,Zap/2')
30
30
  agents = subject.to_a
31
31
  agents.size.should > 0
32
32
  agents.each do |agent|
@@ -35,30 +35,30 @@ module Adhearsion::Asterisk
35
35
  end
36
36
 
37
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"
38
+ mock_ee.should_receive(:execute).once.with("AddQueueMember", queue_name, agent_channel, "", "", "", "")
39
+ mock_ee.should_receive(:get_variable).once.with('AQMSTATUS').and_return('ADDED')
40
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").and_return "Agent/007,SIP/2302,Local/2510@from-internal"
41
41
  subject.new agent_channel
42
42
  end
43
43
 
44
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')
45
+ mock_ee.should_receive(:execute).once.with("AddQueueMember", queue_name, agent_channel, "", "", "", "")
46
+ mock_ee.should_receive(:get_variable).once.with('AQMSTATUS').and_return('NOSUCHQUEUE')
47
47
  lambda {
48
48
  subject.new agent_channel
49
49
  }.should raise_error QueueDoesNotExistError
50
50
  end
51
51
 
52
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"
53
+ mock_ee.should_receive(:get_variable).once.with("AQMSTATUS").and_return("ADDED")
54
+ mock_ee.should_receive(:execute).once.with("AddQueueMember", queue_name, agent_channel, "", "", "", "")
55
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").and_return "Agent/007,SIP/2302,Local/2510@from-internal"
56
56
  subject.new(agent_channel).should be_a AgentProxy
57
57
  end
58
58
 
59
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, "", "", "", "")
60
+ mock_ee.should_receive(:get_variable).once.with("AQMSTATUS").and_return("MEMBERALREADY")
61
+ mock_ee.should_receive(:execute).once.with("AddQueueMember", queue_name, agent_channel, "", "", "", "")
62
62
  subject.new(agent_channel).should be false
63
63
  end
64
64
 
@@ -69,61 +69,61 @@ module Adhearsion::Asterisk
69
69
  end
70
70
 
71
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"
72
+ mock_ee.should_receive(:execute).once.with('AddQueueMember', queue_name, agent_channel, 10, '', '','')
73
+ mock_ee.should_receive(:get_variable).once.with('AQMSTATUS').and_return('ADDED')
74
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").and_return "Agent/007,SIP/2302,Local/2510@from-internal"
75
75
  subject.new agent_channel, :penalty => 10
76
76
  end
77
77
 
78
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"
79
+ mock_ee.should_receive(:execute).once.with('AddQueueMember', queue_name, agent_channel, '', '', '','SIP/2302')
80
+ mock_ee.should_receive(:get_variable).once.with('AQMSTATUS').and_return('ADDED')
81
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").and_return "Agent/007,SIP/2302,Local/2510@from-internal"
82
82
  subject.new agent_channel, :state_interface => 'SIP/2302'
83
83
  end
84
84
 
85
85
  it 'should execute AddQueueMember properly when the name is given' do
86
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"
87
+ mock_ee.should_receive(:execute).once.with('AddQueueMember', queue_name, agent_channel, '', '', agent_name,'')
88
+ mock_ee.should_receive(:get_variable).once.with('AQMSTATUS').and_return('ADDED')
89
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").and_return "Agent/007,SIP/2302,Local/2510@from-internal"
90
90
  subject.new agent_channel, :name => agent_name
91
91
  end
92
92
 
93
93
  it 'should execute AddQueueMember properly when the name, penalty, and interface is given' do
94
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"
95
+ mock_ee.should_receive(:execute).once.with('AddQueueMember', queue_name, agent_channel, penalty, '', agent_name,'')
96
+ mock_ee.should_receive(:get_variable).once.with('AQMSTATUS').and_return('ADDED')
97
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").and_return "Agent/007,SIP/2302,Local/2510@from-internal"
98
98
  subject.new agent_channel, :name => agent_name, :penalty => penalty
99
99
  end
100
100
 
101
101
  it 'should execute AddQueueMember properly when the name, penalty, interface, and state_interface is given' do
102
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"
103
+ mock_ee.should_receive(:execute).once.with('AddQueueMember', queue_name, agent_channel, penalty, '', agent_name, state_interface)
104
+ mock_ee.should_receive(:get_variable).once.with('AQMSTATUS').and_return('ADDED')
105
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_MEMBER_LIST(#{queue_name})").and_return "Agent/007,SIP/2302,Local/2510@from-internal"
106
106
  subject.new agent_channel, :name => agent_name, :penalty => penalty, :state_interface => state_interface
107
107
  end
108
108
 
109
109
  it "should log an agent in properly with no agent id given" do
110
- mock_ee.expects(:execute).once.with('AgentLogin', nil, 's')
110
+ mock_ee.should_receive(:execute).once.with('AgentLogin', nil, 's')
111
111
  subject.login!
112
112
  end
113
113
 
114
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')
115
+ mock_ee.should_receive(:execute).once.with('AgentLogin', '007', 's')
116
116
  subject.login! 'Agent/007'
117
117
 
118
- mock_ee.expects(:execute).once.with('AgentLogin', '007', 's')
118
+ mock_ee.should_receive(:execute).once.with('AgentLogin', '007', 's')
119
119
  subject.login! '007'
120
120
  end
121
121
 
122
122
  it 'should add an agent silently properly' do
123
- mock_ee.expects(:execute).once.with('AgentLogin', '007', '')
123
+ mock_ee.should_receive(:execute).once.with('AgentLogin', '007', '')
124
124
  subject.login! 'Agent/007', :silent => false
125
125
 
126
- mock_ee.expects(:execute).once.with('AgentLogin', '008', 's')
126
+ mock_ee.should_receive(:execute).once.with('AgentLogin', '008', 's')
127
127
  subject.login! 'Agent/008', :silent => true
128
128
  end
129
129
 
@@ -19,82 +19,82 @@ module Adhearsion::Asterisk
19
19
 
20
20
  describe '#join' do
21
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"
22
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "", '', '', '', '')
23
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "FULL"
24
24
  subject.join!
25
25
  end
26
26
 
27
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"
28
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "", '', '', '', '')
29
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "TIMEOUT"
30
30
  subject.join!.should be :timeout
31
31
  end
32
32
 
33
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
34
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "", '', '', '', '')
35
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return nil
36
36
  subject.join!.should be :completed
37
37
  end
38
38
 
39
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"
40
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "", '', '', '60', '')
41
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
42
42
  subject.join! :timeout => 1.minute
43
43
  end
44
44
 
45
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"
46
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "", '', 'custom_announcement_file_here', '', '')
47
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
48
48
  subject.join! :announce => 'custom_announcement_file_here'
49
49
  end
50
50
 
51
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"
52
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, '', '', '', '','agi://localhost/queue_agi_test')
53
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINUNAVAIL"
54
54
  subject.join! :agi => 'agi://localhost/queue_agi_test'
55
55
  end
56
56
 
57
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"
58
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "Tt", '', '', '', '')
59
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
60
60
  subject.join! :allow_transfer => :everyone
61
61
 
62
- mock_ee.expects(:execute).once.with("queue", queue_name, "T", '', '', '', '')
63
- mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
62
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "T", '', '', '', '')
63
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
64
64
  subject.join! :allow_transfer => :caller
65
65
 
66
- mock_ee.expects(:execute).once.with("queue", queue_name, "t", '', '', '', '')
67
- mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
66
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "t", '', '', '', '')
67
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
68
68
  subject.join! :allow_transfer => :agent
69
69
  end
70
70
 
71
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"
72
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "Hh", '', '', '', '')
73
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
74
74
  subject.join! :allow_hangup => :everyone
75
75
 
76
- mock_ee.expects(:execute).once.with("queue", queue_name, "H", '', '', '', '')
77
- mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
76
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "H", '', '', '', '')
77
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
78
78
  subject.join! :allow_hangup => :caller
79
79
 
80
- mock_ee.expects(:execute).once.with("queue", queue_name, "h", '', '', '', '')
81
- mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
80
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "h", '', '', '', '')
81
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
82
82
  subject.join! :allow_hangup => :agent
83
83
  end
84
84
 
85
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"
86
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "r", '', '', '', '')
87
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
88
88
  subject.join! :play => :ringing
89
89
 
90
- mock_ee.expects(:execute).once.with("queue", queue_name, "", '', '', '', '')
91
- mock_ee.expects(:get_variable).once.with("QUEUESTATUS").returns "JOINEMPTY"
90
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "", '', '', '', '')
91
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
92
92
  subject.join! :play => :music
93
93
  end
94
94
 
95
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"
96
+ mock_ee.should_receive(:execute).once.with("queue", queue_name, "rtHh", '', '', '120', '')
97
+ mock_ee.should_receive(:get_variable).once.with("QUEUESTATUS").and_return "JOINEMPTY"
98
98
  subject.join! :allow_transfer => :agent, :timeout => 2.minutes,
99
99
  :play => :ringing, :allow_hangup => :everyone
100
100
  end
@@ -115,41 +115,41 @@ module Adhearsion::Asterisk
115
115
  end
116
116
 
117
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"
118
+ mock_ee.should_receive(:execute).once.with("RemoveQueueMember", queue_name, "SIP/AdhearsionQueueExistenceCheck")
119
+ mock_ee.should_receive(:get_variable).once.with("RQMSTATUS").and_return "NOTINQUEUE"
120
120
  subject.exists?.should be true
121
121
 
122
- mock_ee.expects(:execute).once.with("RemoveQueueMember", queue_name, "SIP/AdhearsionQueueExistenceCheck")
123
- mock_ee.expects(:get_variable).once.with("RQMSTATUS").returns "NOSUCHQUEUE"
122
+ mock_ee.should_receive(:execute).once.with("RemoveQueueMember", queue_name, "SIP/AdhearsionQueueExistenceCheck")
123
+ mock_ee.should_receive(:get_variable).once.with("RQMSTATUS").and_return "NOSUCHQUEUE"
124
124
  subject.exists?.should be false
125
125
  end
126
126
 
127
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
128
+ mock_ee.should_receive(:get_variable).once.with("QUEUE_WAITING_COUNT(#{queue_name})").and_return "50"
129
+ subject.should_receive(:exists?).once.and_return true
130
130
  subject.waiting_count.should == 50
131
131
  end
132
132
 
133
133
  it 'waiting_count for a queue that does not exist' do
134
134
  lambda {
135
- subject.expects(:exists?).once.returns false
135
+ subject.should_receive(:exists?).once.and_return false
136
136
  subject.waiting_count
137
137
  }.should raise_error Adhearsion::Asterisk::QueueProxy::QueueDoesNotExistError
138
138
  end
139
139
 
140
140
  it 'empty? should call waiting_count' do
141
- subject.expects(:waiting_count).once.returns 0
141
+ subject.should_receive(:waiting_count).once.and_return 0
142
142
  subject.empty?.should be true
143
143
 
144
- subject.expects(:waiting_count).once.returns 99
144
+ subject.should_receive(:waiting_count).once.and_return 99
145
145
  subject.empty?.should_not be true
146
146
  end
147
147
 
148
148
  it 'any? should call waiting_count' do
149
- subject.expects(:waiting_count).once.returns 0
149
+ subject.should_receive(:waiting_count).once.and_return 0
150
150
  subject.any?.should be false
151
151
 
152
- subject.expects(:waiting_count).once.returns 99
152
+ subject.should_receive(:waiting_count).once.and_return 99
153
153
  subject.any?.should be true
154
154
  end
155
155
  end