adhearsion 1.2.6 → 2.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. data/.gitignore +17 -10
  2. data/CHANGELOG.md +273 -0
  3. data/Gemfile +1 -1
  4. data/Guardfile +17 -0
  5. data/README.markdown +61 -9
  6. data/Rakefile +16 -48
  7. data/adhearsion.gemspec +21 -7
  8. data/bin/ahn +3 -1
  9. data/cucumber.yml +4 -0
  10. data/features/app_generator.feature +42 -0
  11. data/features/cli.feature +108 -0
  12. data/features/step_definitions/app_generator_steps.rb +6 -0
  13. data/features/step_definitions/cli_steps.rb +74 -0
  14. data/features/support/aruba_helper.rb +22 -0
  15. data/features/support/env.rb +37 -0
  16. data/features/support/utils.rb +8 -0
  17. data/lib/adhearsion.rb +85 -41
  18. data/lib/adhearsion/call.rb +176 -0
  19. data/lib/adhearsion/call_controller.rb +134 -0
  20. data/lib/adhearsion/call_controller/dial.rb +70 -0
  21. data/lib/adhearsion/call_controller/input.rb +173 -0
  22. data/lib/adhearsion/call_controller/menu.rb +124 -0
  23. data/lib/adhearsion/call_controller/output.rb +267 -0
  24. data/lib/adhearsion/call_controller/record.rb +42 -0
  25. data/lib/adhearsion/call_controller/utility.rb +60 -0
  26. data/lib/adhearsion/calls.rb +81 -0
  27. data/lib/adhearsion/cli.rb +1 -3
  28. data/lib/adhearsion/cli_commands.rb +142 -0
  29. data/lib/adhearsion/configuration.rb +149 -0
  30. data/lib/adhearsion/console.rb +19 -8
  31. data/lib/adhearsion/dialplan_controller.rb +9 -0
  32. data/lib/adhearsion/events.rb +84 -0
  33. data/lib/adhearsion/foundation/all.rb +0 -7
  34. data/lib/adhearsion/foundation/custom_daemonizer.rb +4 -6
  35. data/lib/adhearsion/foundation/exception_handler.rb +9 -0
  36. data/lib/adhearsion/foundation/object.rb +26 -8
  37. data/lib/adhearsion/foundation/synchronized_hash.rb +3 -6
  38. data/lib/adhearsion/foundation/thread_safety.rb +17 -1
  39. data/lib/adhearsion/generators/app/app_generator.rb +4 -13
  40. data/lib/adhearsion/generators/app/templates/Gemfile +10 -5
  41. data/lib/adhearsion/generators/app/templates/Procfile +1 -0
  42. data/lib/adhearsion/generators/app/templates/README.md +28 -0
  43. data/lib/adhearsion/generators/app/templates/config/adhearsion.rb +41 -0
  44. data/lib/adhearsion/generators/app/templates/{components/simon_game → lib}/simon_game.rb +6 -18
  45. data/lib/adhearsion/generators/app/templates/script/ahn +2 -2
  46. data/lib/adhearsion/initializer.rb +151 -293
  47. data/lib/adhearsion/initializer/logging.rb +33 -0
  48. data/lib/adhearsion/logging.rb +65 -69
  49. data/lib/adhearsion/menu_dsl.rb +15 -0
  50. data/lib/adhearsion/menu_dsl/calculated_match.rb +39 -0
  51. data/lib/adhearsion/menu_dsl/calculated_match_collection.rb +41 -0
  52. data/lib/adhearsion/menu_dsl/fixnum_match_calculator.rb +18 -0
  53. data/lib/adhearsion/menu_dsl/match_calculator.rb +36 -0
  54. data/lib/adhearsion/{voip/menu_state_machine/menu_class.rb → menu_dsl/menu.rb} +38 -40
  55. data/lib/adhearsion/menu_dsl/menu_builder.rb +69 -0
  56. data/lib/adhearsion/menu_dsl/range_match_calculator.rb +55 -0
  57. data/lib/adhearsion/menu_dsl/string_match_calculator.rb +21 -0
  58. data/lib/adhearsion/outbound_call.rb +64 -0
  59. data/lib/adhearsion/plugin.rb +319 -0
  60. data/lib/adhearsion/plugin/collection.rb +19 -0
  61. data/lib/adhearsion/plugin/initializer.rb +37 -0
  62. data/lib/adhearsion/plugin/methods_container.rb +6 -0
  63. data/lib/adhearsion/process.rb +94 -0
  64. data/lib/adhearsion/punchblock_plugin.rb +29 -0
  65. data/lib/adhearsion/punchblock_plugin/initializer.rb +137 -0
  66. data/lib/adhearsion/router.rb +30 -0
  67. data/lib/adhearsion/router/route.rb +42 -0
  68. data/lib/adhearsion/script_ahn_loader.rb +2 -2
  69. data/lib/adhearsion/tasks.rb +14 -9
  70. data/lib/adhearsion/tasks/configuration.rb +26 -0
  71. data/lib/adhearsion/tasks/plugins.rb +17 -0
  72. data/lib/adhearsion/version.rb +8 -14
  73. data/spec/adhearsion/call_controller/dial_spec.rb +138 -0
  74. data/spec/adhearsion/call_controller/input_spec.rb +278 -0
  75. data/spec/adhearsion/call_controller/menu_spec.rb +120 -0
  76. data/spec/adhearsion/call_controller/output_spec.rb +466 -0
  77. data/spec/adhearsion/call_controller/record_spec.rb +125 -0
  78. data/spec/adhearsion/call_controller_spec.rb +395 -0
  79. data/spec/adhearsion/call_spec.rb +438 -0
  80. data/spec/adhearsion/calls_spec.rb +47 -0
  81. data/spec/adhearsion/configuration_spec.rb +308 -0
  82. data/spec/adhearsion/dialplan_controller_spec.rb +26 -0
  83. data/spec/adhearsion/events_spec.rb +112 -0
  84. data/spec/adhearsion/initializer/logging_spec.rb +58 -0
  85. data/spec/adhearsion/initializer_spec.rb +209 -122
  86. data/spec/adhearsion/logging_spec.rb +58 -47
  87. data/spec/adhearsion/menu_dsl/calculated_match_collection_spec.rb +56 -0
  88. data/spec/adhearsion/menu_dsl/calculated_match_spec.rb +57 -0
  89. data/spec/adhearsion/menu_dsl/fixnum_match_calculator_spec.rb +33 -0
  90. data/spec/adhearsion/menu_dsl/match_calculator_spec.rb +13 -0
  91. data/spec/adhearsion/menu_dsl/menu_builder_spec.rb +118 -0
  92. data/spec/adhearsion/menu_dsl/menu_spec.rb +210 -0
  93. data/spec/adhearsion/menu_dsl/range_match_calculator_spec.rb +28 -0
  94. data/spec/adhearsion/menu_dsl/string_match_calculator_spec.rb +36 -0
  95. data/spec/adhearsion/menu_dsl_spec.rb +12 -0
  96. data/spec/adhearsion/outbound_call_spec.rb +174 -0
  97. data/spec/adhearsion/plugin_spec.rb +489 -0
  98. data/spec/adhearsion/process_spec.rb +34 -0
  99. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +294 -0
  100. data/spec/adhearsion/router/route_spec.rb +99 -0
  101. data/spec/adhearsion/router_spec.rb +106 -0
  102. data/spec/adhearsion_spec.rb +46 -0
  103. data/spec/spec_helper.rb +14 -14
  104. data/spec/support/call_controller_test_helpers.rb +48 -0
  105. data/spec/support/initializer_stubs.rb +8 -13
  106. data/spec/support/punchblock_mocks.rb +6 -0
  107. metadata +255 -253
  108. data/CHANGELOG +0 -174
  109. data/bin/ahnctl +0 -68
  110. data/bin/jahn +0 -43
  111. data/examples/asterisk_manager_interface/standalone.rb +0 -51
  112. data/lib/adhearsion/commands.rb +0 -302
  113. data/lib/adhearsion/component_manager.rb +0 -278
  114. data/lib/adhearsion/component_manager/component_tester.rb +0 -54
  115. data/lib/adhearsion/component_manager/spec_framework.rb +0 -18
  116. data/lib/adhearsion/events_support.rb +0 -65
  117. data/lib/adhearsion/foundation/blank_slate.rb +0 -3
  118. data/lib/adhearsion/foundation/event_socket.rb +0 -205
  119. data/lib/adhearsion/foundation/future_resource.rb +0 -36
  120. data/lib/adhearsion/foundation/metaprogramming.rb +0 -17
  121. data/lib/adhearsion/foundation/numeric.rb +0 -13
  122. data/lib/adhearsion/foundation/pseudo_guid.rb +0 -10
  123. data/lib/adhearsion/foundation/relationship_properties.rb +0 -42
  124. data/lib/adhearsion/foundation/string.rb +0 -26
  125. data/lib/adhearsion/generators/app/templates/.ahnrc +0 -34
  126. data/lib/adhearsion/generators/app/templates/README +0 -8
  127. data/lib/adhearsion/generators/app/templates/components/ami_remote/ami_remote.rb +0 -15
  128. data/lib/adhearsion/generators/app/templates/components/disabled/HOW_TO_ENABLE +0 -7
  129. data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/README.markdown +0 -47
  130. data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/stomp_gateway.rb +0 -34
  131. data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/stomp_gateway.yml +0 -12
  132. data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/README.markdown +0 -3
  133. data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/xmpp_gateway.rb +0 -11
  134. data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/xmpp_gateway.yml +0 -0
  135. data/lib/adhearsion/generators/app/templates/config/startup.rb +0 -81
  136. data/lib/adhearsion/generators/app/templates/dialplan.rb +0 -3
  137. data/lib/adhearsion/generators/app/templates/events.rb +0 -33
  138. data/lib/adhearsion/host_definitions.rb +0 -67
  139. data/lib/adhearsion/initializer/asterisk.rb +0 -86
  140. data/lib/adhearsion/initializer/configuration.rb +0 -324
  141. data/lib/adhearsion/initializer/database.rb +0 -60
  142. data/lib/adhearsion/initializer/drb.rb +0 -31
  143. data/lib/adhearsion/initializer/freeswitch.rb +0 -22
  144. data/lib/adhearsion/initializer/ldap.rb +0 -57
  145. data/lib/adhearsion/initializer/rails.rb +0 -41
  146. data/lib/adhearsion/initializer/xmpp.rb +0 -42
  147. data/lib/adhearsion/tasks/components.rb +0 -32
  148. data/lib/adhearsion/tasks/database.rb +0 -5
  149. data/lib/adhearsion/tasks/deprecations.rb +0 -59
  150. data/lib/adhearsion/tasks/generating.rb +0 -20
  151. data/lib/adhearsion/tasks/lint.rb +0 -4
  152. data/lib/adhearsion/voip/asterisk.rb +0 -4
  153. data/lib/adhearsion/voip/asterisk/agi_server.rb +0 -121
  154. data/lib/adhearsion/voip/asterisk/commands.rb +0 -1966
  155. data/lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb +0 -140
  156. data/lib/adhearsion/voip/asterisk/config_generators/config_generator.rb +0 -102
  157. data/lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb +0 -250
  158. data/lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb +0 -240
  159. data/lib/adhearsion/voip/asterisk/config_manager.rb +0 -64
  160. data/lib/adhearsion/voip/asterisk/manager_interface.rb +0 -697
  161. data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb +0 -1681
  162. data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb +0 -341
  163. data/lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb +0 -78
  164. data/lib/adhearsion/voip/asterisk/manager_interface/ami_protocol_lexer_machine.rl +0 -87
  165. data/lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb +0 -80
  166. data/lib/adhearsion/voip/call.rb +0 -521
  167. data/lib/adhearsion/voip/call_routing.rb +0 -64
  168. data/lib/adhearsion/voip/commands.rb +0 -17
  169. data/lib/adhearsion/voip/constants.rb +0 -39
  170. data/lib/adhearsion/voip/conveniences.rb +0 -18
  171. data/lib/adhearsion/voip/dial_plan.rb +0 -252
  172. data/lib/adhearsion/voip/dsl/dialing_dsl.rb +0 -151
  173. data/lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb +0 -37
  174. data/lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb +0 -27
  175. data/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb +0 -124
  176. data/lib/adhearsion/voip/dsl/dialplan/parser.rb +0 -69
  177. data/lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb +0 -16
  178. data/lib/adhearsion/voip/dsl/numerical_string.rb +0 -128
  179. data/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb +0 -48
  180. data/lib/adhearsion/voip/freeswitch/event_handler.rb +0 -58
  181. data/lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb +0 -129
  182. data/lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb +0 -38
  183. data/lib/adhearsion/voip/freeswitch/oes_server.rb +0 -195
  184. data/lib/adhearsion/voip/menu_state_machine/calculated_match.rb +0 -80
  185. data/lib/adhearsion/voip/menu_state_machine/matchers.rb +0 -123
  186. data/lib/adhearsion/voip/menu_state_machine/menu_builder.rb +0 -57
  187. data/lib/adhearsion/xmpp/connection.rb +0 -61
  188. data/lib/theatre.rb +0 -147
  189. data/lib/theatre/README.markdown +0 -64
  190. data/lib/theatre/callback_definition_loader.rb +0 -86
  191. data/lib/theatre/guid.rb +0 -23
  192. data/lib/theatre/invocation.rb +0 -131
  193. data/lib/theatre/namespace_manager.rb +0 -153
  194. data/lib/theatre/version.rb +0 -2
  195. data/spec/adhearsion/cli_spec.rb +0 -306
  196. data/spec/adhearsion/component_manager_spec.rb +0 -292
  197. data/spec/adhearsion/constants_spec.rb +0 -8
  198. data/spec/adhearsion/drb_spec.rb +0 -65
  199. data/spec/adhearsion/fixtures/dialplan.rb +0 -3
  200. data/spec/adhearsion/foundation/event_socket_spec.rb +0 -168
  201. data/spec/adhearsion/host_definitions_spec.rb +0 -79
  202. data/spec/adhearsion/initializer/configuration_spec.rb +0 -291
  203. data/spec/adhearsion/initializer/loading_spec.rb +0 -154
  204. data/spec/adhearsion/initializer/paths_spec.rb +0 -74
  205. data/spec/adhearsion/relationship_properties_spec.rb +0 -54
  206. data/spec/adhearsion/voip/asterisk/agi_server_spec.rb +0 -473
  207. data/spec/adhearsion/voip/asterisk/ami/ami_spec.rb +0 -550
  208. data/spec/adhearsion/voip/asterisk/ami/lexer/ami_fixtures.yml +0 -30
  209. data/spec/adhearsion/voip/asterisk/ami/lexer/lexer_story +0 -291
  210. data/spec/adhearsion/voip/asterisk/ami/lexer/lexer_story.rb +0 -241
  211. data/spec/adhearsion/voip/asterisk/ami/lexer/story_helper.rb +0 -124
  212. data/spec/adhearsion/voip/asterisk/commands_spec.rb +0 -3241
  213. data/spec/adhearsion/voip/asterisk/config_file_generators/agents_spec.rb +0 -251
  214. data/spec/adhearsion/voip/asterisk/config_file_generators/queues_spec.rb +0 -323
  215. data/spec/adhearsion/voip/asterisk/config_file_generators/voicemail_spec.rb +0 -306
  216. data/spec/adhearsion/voip/asterisk/config_manager_spec.rb +0 -127
  217. data/spec/adhearsion/voip/asterisk/menu_command/calculated_match_spec.rb +0 -109
  218. data/spec/adhearsion/voip/asterisk/menu_command/matchers_spec.rb +0 -97
  219. data/spec/adhearsion/voip/call_routing_spec.rb +0 -125
  220. data/spec/adhearsion/voip/dialplan_manager_spec.rb +0 -468
  221. data/spec/adhearsion/voip/dsl/dialing_dsl_spec.rb +0 -270
  222. data/spec/adhearsion/voip/dsl/dispatcher_spec.rb +0 -82
  223. data/spec/adhearsion/voip/dsl/dispatcher_spec_helper.rb +0 -45
  224. data/spec/adhearsion/voip/dsl/parser_spec.rb +0 -69
  225. data/spec/adhearsion/voip/freeswitch/basic_connection_manager_spec.rb +0 -39
  226. data/spec/adhearsion/voip/freeswitch/inbound_connection_manager_spec.rb +0 -39
  227. data/spec/adhearsion/voip/freeswitch/oes_server_spec.rb +0 -9
  228. data/spec/adhearsion/voip/numerical_string_spec.rb +0 -61
  229. data/spec/adhearsion/voip/phone_number_spec.rb +0 -45
  230. data/spec/support/the_following_code.rb +0 -3
  231. data/spec/theatre/dsl_examples/simple_before_call.rb +0 -7
  232. data/spec/theatre/dsl_spec.rb +0 -69
  233. data/spec/theatre/invocation_spec.rb +0 -182
  234. data/spec/theatre/namespace_spec.rb +0 -125
  235. data/spec/theatre/spec_helper_spec.rb +0 -28
  236. data/spec/theatre/theatre_class_spec.rb +0 -148
@@ -1,251 +0,0 @@
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
@@ -1,323 +0,0 @@
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