adhearsion 1.0.1 → 1.0.2

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 (64) hide show
  1. data/.gitignore +10 -0
  2. data/CHANGELOG +8 -0
  3. data/README.markdown +33 -0
  4. data/Rakefile +28 -68
  5. data/adhearsion.gemspec +19 -133
  6. data/app_generators/ahn/templates/Gemfile +0 -4
  7. data/app_generators/ahn/templates/components/disabled/restful_rpc/spec/restful_rpc_spec.rb +4 -16
  8. data/lib/adhearsion/cli.rb +17 -0
  9. data/lib/adhearsion/component_manager/component_tester.rb +1 -3
  10. data/lib/adhearsion/component_manager/spec_framework.rb +4 -10
  11. data/lib/adhearsion/foundation/object.rb +10 -0
  12. data/lib/adhearsion/version.rb +1 -1
  13. data/spec/ahn_command_spec.rb +284 -0
  14. data/spec/component_manager_spec.rb +292 -0
  15. data/spec/constants_spec.rb +8 -0
  16. data/spec/drb_spec.rb +65 -0
  17. data/spec/fixtures/dialplan.rb +3 -0
  18. data/spec/foundation/event_socket_spec.rb +168 -0
  19. data/spec/host_definitions_spec.rb +79 -0
  20. data/spec/initialization_spec.rb +163 -0
  21. data/spec/initializer/configuration_spec.rb +270 -0
  22. data/spec/initializer/loading_spec.rb +149 -0
  23. data/spec/initializer/paths_spec.rb +74 -0
  24. data/spec/logging_spec.rb +86 -0
  25. data/spec/relationship_properties_spec.rb +54 -0
  26. data/spec/silence.rb +10 -0
  27. data/spec/spec_helper.rb +101 -0
  28. data/spec/voip/asterisk/agi_server_spec.rb +473 -0
  29. data/spec/voip/asterisk/ami/ami_spec.rb +549 -0
  30. data/spec/voip/asterisk/ami/lexer/ami_fixtures.yml +30 -0
  31. data/spec/voip/asterisk/ami/lexer/lexer_story +291 -0
  32. data/spec/voip/asterisk/ami/lexer/lexer_story.rb +241 -0
  33. data/spec/voip/asterisk/ami/lexer/story_helper.rb +124 -0
  34. data/spec/voip/asterisk/ami/old_tests.rb +204 -0
  35. data/spec/voip/asterisk/ami/super_manager/super_manager_story +25 -0
  36. data/spec/voip/asterisk/ami/super_manager/super_manager_story.rb +15 -0
  37. data/spec/voip/asterisk/ami/super_manager/super_manager_story_helper.rb +5 -0
  38. data/spec/voip/asterisk/commands_spec.rb +2179 -0
  39. data/spec/voip/asterisk/config_file_generators/agents_spec.rb +251 -0
  40. data/spec/voip/asterisk/config_file_generators/queues_spec.rb +323 -0
  41. data/spec/voip/asterisk/config_file_generators/voicemail_spec.rb +306 -0
  42. data/spec/voip/asterisk/config_manager_spec.rb +127 -0
  43. data/spec/voip/asterisk/menu_command/calculated_match_spec.rb +109 -0
  44. data/spec/voip/asterisk/menu_command/matchers_spec.rb +97 -0
  45. data/spec/voip/call_routing_spec.rb +125 -0
  46. data/spec/voip/dialplan_manager_spec.rb +468 -0
  47. data/spec/voip/dsl/dialing_dsl_spec.rb +270 -0
  48. data/spec/voip/dsl/dispatcher_spec.rb +82 -0
  49. data/spec/voip/dsl/dispatcher_spec_helper.rb +45 -0
  50. data/spec/voip/dsl/parser_spec.rb +69 -0
  51. data/spec/voip/freeswitch/basic_connection_manager_spec.rb +39 -0
  52. data/spec/voip/freeswitch/inbound_connection_manager_spec.rb +39 -0
  53. data/spec/voip/freeswitch/oes_server_spec.rb +9 -0
  54. data/spec/voip/numerical_string_spec.rb +61 -0
  55. data/spec/voip/phone_number_spec.rb +45 -0
  56. data/theatre-spec/dsl_examples/dynamic_stomp.rb +7 -0
  57. data/theatre-spec/dsl_examples/simple_before_call.rb +7 -0
  58. data/theatre-spec/dsl_spec.rb +43 -0
  59. data/theatre-spec/invocation_spec.rb +167 -0
  60. data/theatre-spec/namespace_spec.rb +125 -0
  61. data/theatre-spec/spec_helper.rb +37 -0
  62. data/theatre-spec/spec_helper_spec.rb +28 -0
  63. data/theatre-spec/theatre_class_spec.rb +150 -0
  64. metadata +171 -34
@@ -0,0 +1,251 @@
1
+ require 'spec_helper'
2
+ require 'adhearsion/voip/asterisk/config_generators/agents.conf'
3
+
4
+ module AgentsConfigFileGeneratorTestHelper
5
+
6
+ def reset_agents!
7
+ @agents = Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Agents.new
8
+ end
9
+
10
+ def generated_config_has_pair(pair)
11
+ agents.conf.split("\n").grep(/=[^>]/).each do |line|
12
+ key, value = line.strip.split('=')
13
+ return true if pair == {key.to_sym => value}
14
+ end
15
+ false
16
+ end
17
+
18
+ end
19
+
20
+ describe "The agents.conf config file agents" do
21
+
22
+ include AgentsConfigFileGeneratorTestHelper
23
+
24
+ attr_reader :agents
25
+ before(:each) do
26
+ reset_agents!
27
+ end
28
+ it "The agent() method should enqueue a Hash into Agents#agent_definitions" do
29
+ agents.agent 1337, :password => 9876, :name => "Jay Phillips"
30
+ agents.agent_definitions.size.should be 1
31
+ agents.agent_definitions.first.should == {:id => 1337, :password => 9876, :name => "Jay Phillips"}
32
+ end
33
+
34
+ it 'should add the warning message to the to_s output' do
35
+ agents.conf.should =~ /^\s*;.{10}/
36
+ end
37
+
38
+ it "The conf() method should always create a general section" do
39
+ agents.conf.should =~ /^\[general\]/
40
+ end
41
+
42
+ it "The agent() method should generate a proper String" do
43
+ agents.agent 123, :name => "Otto Normalverbraucher", :password => "007"
44
+ agents.agent 889, :name => "John Doe", :password => "998"
45
+
46
+ agents.conf.split("\n").grep(/^agent =>/).map(&:strip).should == [
47
+ "agent => 123,007,Otto Normalverbraucher",
48
+ "agent => 889,998,John Doe"
49
+ ]
50
+ end
51
+
52
+ it "The persistent_agents() method should generate a persistentagents yes/no pair" do
53
+ agents.persistent_agents true
54
+ generated_config_has_pair(:persistentagents => "yes").should be true
55
+
56
+ reset_agents!
57
+
58
+ agents.persistent_agents false
59
+ generated_config_has_pair(:persistentagents => "no").should be true
60
+ end
61
+
62
+ it "The persistent_agents() method should be in the [general] section" do
63
+ agents.persistent_agents true
64
+ agents.general_section.should == {:persistentagents => "yes"}
65
+
66
+ end
67
+
68
+ it "max_login_tries() should generate a 'maxlogintries' numerical pair" do
69
+ agents.max_login_tries 50
70
+ generated_config_has_pair(:maxlogintries => "50").should be true
71
+ end
72
+
73
+ it "max_login_tries() should be in the agents section" do
74
+ agents.max_login_tries 0
75
+ agents.agent_section.should == {:maxlogintries => 0}
76
+ end
77
+
78
+ it "log_off_after_duration should generate autologoff" do
79
+ agents.log_off_after_duration 15.seconds
80
+ generated_config_has_pair(:autologoff => "15").should be true
81
+ end
82
+
83
+ it "log_off_if_unavailable should add autologoffunavail to the agents section" do
84
+ agents.log_off_if_unavailable false
85
+ agents.agent_section.should == {:autologoffunavail => "no"}
86
+ end
87
+
88
+ it "require_hash_to_acknowledge() should generate a 'ackcall' yes/no pair" do
89
+ agents.require_hash_to_acknowledge false
90
+ agents.agent_section.should == {:ackcall => "no"}
91
+ end
92
+
93
+ it "allow_star_to_hangup should generate a 'endcall' yes/no pair" do
94
+ agents.allow_star_to_hangup false
95
+ agents.agent_section.should == {:endcall => "no"}
96
+ end
97
+
98
+ it "time_between_calls should convert its argument to milliseconds" do
99
+ agents.time_between_calls 1.hour
100
+ agents.agent_section.should == {:wrapuptime => 1.hour * 1_000}
101
+ end
102
+
103
+ it "hold_music_class should convert its argument to a String" do
104
+ agents.hold_music_class :podcast
105
+ agents.agent_section_special.should == {:musiconhold => "podcast"}
106
+ end
107
+
108
+ it "play_on_agent_goodbye should generate 'agentgoodbye'" do
109
+ agents.play_on_agent_goodbye "tt-monkeys"
110
+ agents.agent_section_special.should == {:agentgoodbye => "tt-monkeys"}
111
+ end
112
+
113
+ it "change_cdr_source should generate updatecdr" do
114
+ agents.change_cdr_source false
115
+ agents.agent_section.should == {:updatecdr => "no"}
116
+ end
117
+
118
+ it "play_for_waiting_keep_alive" do
119
+ agents.play_for_waiting_keep_alive "tt-weasels"
120
+ agents.agent_section.should == {:custom_beep => "tt-weasels"}
121
+ end
122
+
123
+ it "save_recordings_in should generate 'savecallsin'" do
124
+ agents.save_recordings_in "/second/star/on/the/right"
125
+ agents.agent_section.should == {:savecallsin => "/second/star/on/the/right"}
126
+ end
127
+
128
+ it "recording_prefix should generate 'urlprefix'" do
129
+ agents.recording_prefix "ohai"
130
+ agents.agent_section.should == {:urlprefix => "ohai"}
131
+ end
132
+
133
+ it "recording_format should only allow a few symbols as an argument" do
134
+ the_following_code {
135
+ agents.recording_format :wav
136
+ agents.agent_section.should == {:recordformat => :wav}
137
+ }.should_not raise_error
138
+
139
+ reset_agents!
140
+
141
+ the_following_code {
142
+ agents.recording_format :wav49
143
+ agents.agent_section.should == {:recordformat => :wav49}
144
+ }.should_not raise_error
145
+
146
+ reset_agents!
147
+
148
+ the_following_code {
149
+ agents.recording_format :gsm
150
+ agents.agent_section.should == {:recordformat => :gsm}
151
+ }.should_not raise_error
152
+
153
+ reset_agents!
154
+
155
+ the_following_code {
156
+ agents.recording_format :mp3
157
+ agents.agent_section.should == {:recordformat => :mp3}
158
+ }.should raise_error ArgumentError
159
+
160
+ end
161
+
162
+ it "record_agent_calls should generate a 'recordagentcalls' yes/no pair" do
163
+ agents.record_agent_calls false
164
+ agents.agent_section.should == {:recordagentcalls => 'no'}
165
+ end
166
+
167
+ it "allow_multiple_logins_per_extension should generate 'multiplelogin' in [general]" do
168
+ agents.allow_multiple_logins_per_extension true
169
+ agents.general_section.should == {:multiplelogin => 'yes'}
170
+ end
171
+
172
+ end
173
+
174
+ describe "The default agents.conf config file converted to this syntax" do
175
+
176
+ include AgentsConfigFileGeneratorTestHelper
177
+
178
+ attr_reader :default_config, :agents
179
+ before(:each) do
180
+ reset_agents!
181
+ @default_config = <<-CONFIG
182
+ [general]
183
+ persistentagents=yes
184
+
185
+ [agents]
186
+ maxlogintries=5
187
+ autologoff=15
188
+ ackcall=no
189
+ endcall=yes
190
+ wrapuptime=5000
191
+ musiconhold => default
192
+ agentgoodbye => goodbye_file
193
+ updatecdr=no
194
+ group=1,2
195
+ recordagentcalls=yes
196
+ recordformat=gsm
197
+ urlprefix=http://localhost/calls/
198
+ savecallsin=/var/calls
199
+ custom_beep=beep
200
+
201
+ agent => 1001,4321,Mark Spencer
202
+ agent => 1002,4321,Will Meadows
203
+ CONFIG
204
+ end
205
+
206
+ it "they're basically the same" do
207
+ agents.persistent_agents true
208
+ agents.max_login_tries 5
209
+ agents.log_off_after_duration 15
210
+ agents.require_hash_to_acknowledge false
211
+ agents.allow_star_to_hangup true
212
+ agents.time_between_calls 5
213
+ agents.hold_music_class :default
214
+ agents.play_on_agent_goodbye "goodbye_file"
215
+ agents.change_cdr_source false
216
+ agents.groups 1,2
217
+ agents.record_agent_calls true
218
+ agents.recording_format :gsm
219
+ agents.recording_prefix "http://localhost/calls/"
220
+ agents.save_recordings_in "/var/calls"
221
+ agents.play_for_waiting_keep_alive "beep"
222
+
223
+ agents.agent 1001, :password => 4321, :name => "Mark Spencer"
224
+ agents.agent 1002, :password => 4321, :name => "Will Meadows"
225
+
226
+ cleaned_up_default_config = Adhearsion::VoIP::Asterisk::ConfigFileGenerators::
227
+ AsteriskConfigGenerator.create_sanitary_hash_from(default_config)
228
+
229
+ cleaned_up_generated_config = agents.to_sanitary_hash
230
+
231
+ cleaned_up_generated_config.should == cleaned_up_default_config
232
+ end
233
+
234
+ end
235
+
236
+
237
+ describe "AgentsConfigFileGeneratorTestHelper" do
238
+
239
+ include AgentsConfigFileGeneratorTestHelper
240
+
241
+ attr_reader :agents
242
+
243
+ it "generated_config_has_pair() works properly" do
244
+ @agents = flexmock "A fake agents with just one pair", :conf => "foo=bar"
245
+ generated_config_has_pair(:foo => "bar").should be true
246
+
247
+ @agents = flexmock "A fake agents with just one pair", :conf => "[general]\n\nqaz=qwerty\nagent => 1,2,3"
248
+ generated_config_has_pair(:qaz => "qwerty").should be true
249
+ generated_config_has_pair(:foo => "bar").should be false
250
+ end
251
+ end
@@ -0,0 +1,323 @@
1
+ require 'spec_helper'
2
+ require 'adhearsion/voip/asterisk/config_generators/queues.conf'
3
+
4
+ module QueuesConfigFileGeneratorTestHelper
5
+
6
+ def reset_queues!
7
+ @queues = Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Queues.new
8
+ end
9
+
10
+ def generated_config_should_have_pair(pair)
11
+ generated_config_has_pair(pair).should be true
12
+ end
13
+
14
+ def generated_config_has_pair(pair)
15
+ queues.to_s.split("\n").grep(/=[^>]/).each do |line|
16
+ key, value = line.strip.split('=')
17
+ return true if pair == {key.to_sym => value}
18
+ end
19
+ false
20
+ end
21
+ end
22
+
23
+ describe "The queues.conf config file generator" do
24
+
25
+ include QueuesConfigFileGeneratorTestHelper
26
+
27
+ attr_reader :queues
28
+ before(:each) do
29
+ reset_queues!
30
+ end
31
+
32
+ it 'should set autofill=yes by default' do
33
+ generated_config_should_have_pair :autofill => 'yes'
34
+ end
35
+
36
+ it 'should have a [general] section' do
37
+ queues.conf.should include "[general]\n"
38
+ end
39
+
40
+ it 'should yield a Queues object in its constructor' do
41
+ Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Queues.new do |config|
42
+ config.should be_a_kind_of Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Queues
43
+ end
44
+ end
45
+
46
+ it 'should add the warning message to the to_s output' do
47
+ queues.conf.should =~ /^\s*;.{10}/
48
+ end
49
+
50
+ end
51
+
52
+ describe "The queues.conf config file queues's QueueDefinition" do
53
+
54
+ include QueuesConfigFileGeneratorTestHelper
55
+
56
+ attr_reader :queues
57
+ before(:each) do
58
+ reset_queues!
59
+ end
60
+
61
+ it 'should include [queue_name]' do
62
+ name_of_queue = "leet_hax0rz"
63
+ queues.queue(name_of_queue).to_s.should include "[#{name_of_queue}]"
64
+ end
65
+
66
+ it '#member should create a valid Agent "channel driver" to the member definition list' do
67
+ sample_queue = queues.queue "sales" do |sales|
68
+ sales.member 123
69
+ sales.member "Jay"
70
+ sales.member 'SIP/jay-desk-650'
71
+ sales.member 'IAX2/12345@voipms/15554443333'
72
+ end
73
+ sample_queue.members.should == %w[Agent/123 Agent/Jay SIP/jay-desk-650 IAX2/12345@voipms/15554443333]
74
+ end
75
+
76
+ it 'should automatically enable the two AMI-related events' do
77
+ @queues = queues.queue 'name'
78
+ generated_config_should_have_pair :eventwhencalled => 'vars'
79
+ generated_config_should_have_pair :eventmemberstatus => 'yes'
80
+ end
81
+
82
+ it '#strategy should only allow the pre-defined settings' do
83
+ [:ringall, :roundrobin, :leastrecent, :fewestcalls, :random, :rrmemory].each do |strategy|
84
+ the_following_code {
85
+ q = queues.queue 'foobar'
86
+ q.strategy strategy
87
+ }.should_not raise_error
88
+ end
89
+
90
+ the_following_code {
91
+ queues.queue('qwerty').strategy :this_is_not_a_valid_strategy
92
+ }.should raise_error ArgumentError
93
+
94
+ end
95
+
96
+ it '#sound_files raises an argument error when it sees an unrecognized key' do
97
+ the_following_code {
98
+ queues.queue 'foobar' do |foobar|
99
+ foobar.sound_files \
100
+ :you_are_next => rand.to_s,
101
+ :there_are => rand.to_s,
102
+ :calls_waiting => rand.to_s,
103
+ :hold_time => rand.to_s,
104
+ :minutes => rand.to_s,
105
+ :seconds => rand.to_s,
106
+ :thank_you => rand.to_s,
107
+ :less_than => rand.to_s,
108
+ :report_hold => rand.to_s,
109
+ :periodic_announcement => rand.to_s
110
+ end
111
+ }.should_not raise_error
112
+
113
+ [:x_you_are_next, :x_there_are, :x_calls_waiting, :x_hold_time, :x_minutes,
114
+ :x_seconds, :x_thank_you, :x_less_than, :x_report_hold, :x_periodic_announcement].each do |bad_key|
115
+ the_following_code {
116
+ queues.queue("foobar") do |foobar|
117
+ foobar.sound_files bad_key => rand.to_s
118
+ end
119
+ }.should raise_error ArgumentError
120
+ end
121
+
122
+ end
123
+
124
+ end
125
+
126
+ describe "The private, helper methods in QueueDefinition" do
127
+
128
+ include QueuesConfigFileGeneratorTestHelper
129
+
130
+ attr_reader :queue
131
+ before(:each) do
132
+ reset_queues!
133
+ @queue = @queues.queue "doesn't matter"
134
+ end
135
+
136
+ it '#boolean should convert a boolean into "yes" or "no"' do
137
+ mock_of_properties = flexmock "mock of the properties instance variable of a QueueDefinition"
138
+ mock_of_properties.should_receive(:[]=).once.with("icanhascheezburger", "yes")
139
+ flexmock(queue).should_receive(:properties).and_return mock_of_properties
140
+ queue.send(:boolean, "icanhascheezburger" => true)
141
+ end
142
+
143
+ it '#int should raise an argument error when its argument is not Numeric' do
144
+ the_following_code {
145
+ queue.send(:int, "eisley" => :i_break_things!)
146
+ }.should raise_error ArgumentError
147
+ end
148
+
149
+ it '#int should coerce a String into a Numeric if possible' do
150
+ mock_of_properties = flexmock "mock of the properties instance variable of a QueueDefinition"
151
+ mock_of_properties.should_receive(:[]=).once.with("chimpanzee", 1337)
152
+ flexmock(queue).should_receive(:properties).and_return mock_of_properties
153
+ queue.send(:int, "chimpanzee" => "1337")
154
+ end
155
+
156
+ it '#string should add the argument directly to the properties' do
157
+ mock_of_properties = flexmock "mock of the properties instance variable of a QueueDefinition"
158
+ mock_of_properties.should_receive(:[]=).once.with("eins", "zwei")
159
+ flexmock(queue).should_receive(:properties).and_return mock_of_properties
160
+ queue.send(:string, "eins" => "zwei")
161
+ end
162
+
163
+ it '#one_of() should add its successful match to the properties attribute' do
164
+ mock_properties = flexmock "mock of the properties instance variable of a QueueDefinition"
165
+ mock_properties.should_receive(:[]=).once.with(:doesnt_matter, 5)
166
+ flexmock(queue).should_receive(:properties).once.and_return mock_properties
167
+
168
+ queue.send(:one_of, 1..100, :doesnt_matter => 5)
169
+ end
170
+
171
+ it "one_of() should convert booleans to yes/no" do
172
+ mock_properties = flexmock "mock of the properties instance variable of a QueueDefinition"
173
+ mock_properties.should_receive(:[]=).once.with(:doesnt_matter, 'yes')
174
+ flexmock(queue).should_receive(:properties).once.and_return mock_properties
175
+ queue.send(:one_of, [true, false, :strict], :doesnt_matter => true)
176
+
177
+ mock_properties = flexmock "mock of the properties instance variable of a QueueDefinition"
178
+ mock_properties.should_receive(:[]=).once.with(:doesnt_matter, :strict)
179
+ flexmock(queue).should_receive(:properties).once.and_return mock_properties
180
+ queue.send(:one_of, [true, false, :strict], :doesnt_matter => :strict)
181
+
182
+ mock_properties = flexmock "mock of the properties instance variable of a QueueDefinition"
183
+ mock_properties.should_receive(:[]=).once.with(:doesnt_matter, 'no')
184
+ flexmock(queue).should_receive(:properties).once.and_return mock_properties
185
+ queue.send(:one_of, [true, false, :strict], :doesnt_matter => false)
186
+ end
187
+
188
+ it '#one_of() should raise an ArgumentError if a value is not in the criteria' do
189
+ the_following_code {
190
+ queue.send(:one_of, [:jay, :thomas, :phillips], :sister => :jill)
191
+ }.should raise_error ArgumentError
192
+ end
193
+ end
194
+
195
+ describe 'The queues.conf config file generator when ran against a really big example' do
196
+
197
+ include QueuesConfigFileGeneratorTestHelper
198
+
199
+ attr_reader :queues, :default_config
200
+ before(:each) do
201
+ reset_queues!
202
+ @default_config = default_config = <<-CONFIG
203
+ [general]
204
+ persistentmembers=yes
205
+ autofill=yes
206
+ monitor-type=MixMonitor
207
+
208
+ [markq]
209
+ musicclass=default
210
+ announce=queue-markq
211
+ strategy=ringall
212
+ servicelevel=60
213
+ context=qoutcon
214
+ timeout=15
215
+ retry=5
216
+ weight=0
217
+ wrapuptime=15
218
+ autofill=yes
219
+ autopause=yes
220
+ maxlen=0
221
+ setinterfacevar=yes
222
+ announce-frequency=90
223
+ periodic-announce-frequency=60
224
+ announce-holdtime=once
225
+ announce-round-seconds=10
226
+ queue-youarenext=queue-youarenext
227
+ queue-thereare=queue-thereare
228
+ queue-callswaiting=queue-callswaiting
229
+ queue-holdtime=queue-holdtime
230
+ queue-minutes=queue-minutes
231
+ queue-seconds=queue-seconds
232
+ queue-thankyou=queue-thankyou
233
+ queue-lessthan=queue-less-than
234
+ queue-reporthold=queue-reporthold
235
+ periodic-announce=queue-periodic-announce
236
+ monitor-format=gsm
237
+ monitor-type=MixMonitor
238
+ joinempty=yes
239
+ leavewhenempty=yes
240
+ eventwhencalled=vars
241
+ eventmemberstatus=yes
242
+ reportholdtime=no
243
+ ringinuse=no
244
+ memberdelay=0
245
+ timeoutrestart=no
246
+
247
+ member => Zap/1
248
+ member => Agent/007
249
+ CONFIG
250
+ end
251
+
252
+ it "a sample config with multiple queues" do
253
+
254
+ generated = Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Queues.new do |config|
255
+ config.persistent_members true
256
+ config.monitor_type :mix_monitor
257
+
258
+ config.queue 'markq' do |markq|
259
+ markq.music_class :default
260
+ markq.play_on_connect 'queue-markq'
261
+ markq.strategy :ringall
262
+ markq.service_level 60
263
+ markq.exit_to_context_on_digit_press 'qoutcon'
264
+ markq.ring_timeout 15
265
+ markq.retry_after_waiting 5
266
+ markq.weight 0
267
+ markq.wrapup_time 15
268
+ markq.autopause true
269
+ markq.maximum_length 0
270
+ markq.queue_status_announce_frequency 90
271
+ markq.announce_hold_time :once
272
+ markq.announce_round_seconds 10
273
+ markq.sound_files \
274
+ :you_are_next => "queue-youarenext",
275
+ :there_are => "queue-thereare",
276
+ :calls_waiting => "queue-callswaiting",
277
+ :hold_time => "queue-holdtime",
278
+ :minutes => "queue-minutes",
279
+ :seconds => "queue-seconds",
280
+ :thank_you => "queue-thankyou",
281
+ :less_than => "queue-less-than",
282
+ :report_hold => "queue-reporthold"
283
+ markq.periodically_announce "queue-periodic-announce"
284
+ markq.monitor_format :gsm
285
+ markq.monitor_type :mix_monitor
286
+ markq.join_empty true
287
+ markq.leave_when_empty true
288
+ markq.report_hold_time false
289
+ markq.ring_in_use false
290
+ markq.delay_connection_by 0
291
+ markq.timeout_restart false
292
+
293
+ markq.member 'Zap/1'
294
+ markq.member '007'
295
+ end
296
+ end
297
+
298
+ cleaned_up_default_config = Adhearsion::VoIP::Asterisk::ConfigFileGenerators::
299
+ AsteriskConfigGenerator.create_sanitary_hash_from(default_config)
300
+
301
+ cleaned_up_generated_config = generated.to_sanitary_hash
302
+
303
+ cleaned_up_generated_config.should == cleaned_up_default_config
304
+ end
305
+
306
+ end
307
+
308
+ describe "ConfigFileGeneratorTestHelper" do
309
+
310
+ include QueuesConfigFileGeneratorTestHelper
311
+
312
+ attr_reader :queues
313
+
314
+ it "generated_config_has_pair() works properly" do
315
+ @queues = flexmock "A fake queues with just one pair", :to_s => "foo=bar"
316
+ generated_config_has_pair(:foo => "bar").should be true
317
+
318
+ @queues = flexmock "A fake queues with just one pair", :to_s => "[general]\n\nqaz=qwerty\nagent => 1,2,3"
319
+ generated_config_has_pair(:qaz => "qwerty").should be true
320
+ generated_config_has_pair(:foo => "bar").should be false
321
+ end
322
+
323
+ end