adhearsion 2.0.0.beta1 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -4
- data/CHANGELOG.md +34 -4
- data/README.markdown +2 -1
- data/Rakefile +22 -1
- data/adhearsion.gemspec +1 -0
- data/bin/ahn +0 -2
- data/features/cli_daemon.feature +2 -0
- data/features/cli_restart.feature +19 -0
- data/features/cli_start.feature +4 -6
- data/features/cli_stop.feature +3 -0
- data/features/step_definitions/app_generator_steps.rb +2 -0
- data/features/step_definitions/cli_steps.rb +2 -0
- data/features/support/aruba_helper.rb +2 -0
- data/features/support/env.rb +8 -46
- data/features/support/utils.rb +2 -0
- data/lib/adhearsion.rb +4 -6
- data/lib/adhearsion/call.rb +71 -17
- data/lib/adhearsion/call_controller.rb +25 -14
- data/lib/adhearsion/call_controller/dial.rb +34 -15
- data/lib/adhearsion/call_controller/input.rb +186 -144
- data/lib/adhearsion/call_controller/output.rb +10 -6
- data/lib/adhearsion/call_controller/record.rb +11 -13
- data/lib/adhearsion/call_controller/utility.rb +2 -0
- data/lib/adhearsion/calls.rb +4 -2
- data/lib/adhearsion/cli.rb +4 -0
- data/lib/adhearsion/cli_commands.rb +8 -2
- data/lib/adhearsion/configuration.rb +7 -3
- data/lib/adhearsion/console.rb +17 -17
- data/lib/adhearsion/events.rb +10 -4
- data/lib/adhearsion/foundation.rb +9 -0
- data/lib/adhearsion/foundation/custom_daemonizer.rb +3 -1
- data/lib/adhearsion/foundation/exception_handler.rb +2 -0
- data/lib/adhearsion/foundation/libc.rb +2 -0
- data/lib/adhearsion/foundation/object.rb +3 -0
- data/lib/adhearsion/foundation/thread_safety.rb +5 -11
- data/lib/adhearsion/generators.rb +2 -0
- data/lib/adhearsion/generators/app/app_generator.rb +2 -0
- data/lib/adhearsion/generators/app/templates/README.md +9 -0
- data/lib/adhearsion/generators/app/templates/config/adhearsion.rb +38 -16
- data/lib/adhearsion/generators/app/templates/config/environment.rb +2 -0
- data/lib/adhearsion/generators/app/templates/lib/simon_game.rb +5 -3
- data/lib/adhearsion/generators/controller/controller_generator.rb +2 -0
- data/lib/adhearsion/generators/controller/templates/lib/controller.rb +2 -0
- data/lib/adhearsion/generators/controller/templates/spec/controller_spec.rb +2 -0
- data/lib/adhearsion/generators/generator.rb +3 -1
- data/lib/adhearsion/generators/plugin/plugin_generator.rb +2 -0
- data/lib/adhearsion/initializer.rb +31 -17
- data/lib/adhearsion/linux_proc_name.rb +2 -0
- data/lib/adhearsion/logging.rb +5 -3
- data/lib/adhearsion/menu_dsl.rb +2 -0
- data/lib/adhearsion/menu_dsl/calculated_match.rb +2 -0
- data/lib/adhearsion/menu_dsl/calculated_match_collection.rb +2 -0
- data/lib/adhearsion/menu_dsl/fixnum_match_calculator.rb +2 -0
- data/lib/adhearsion/menu_dsl/match_calculator.rb +2 -0
- data/lib/adhearsion/menu_dsl/menu.rb +58 -4
- data/lib/adhearsion/menu_dsl/menu_builder.rb +14 -1
- data/lib/adhearsion/menu_dsl/range_match_calculator.rb +4 -1
- data/lib/adhearsion/menu_dsl/string_match_calculator.rb +2 -0
- data/lib/adhearsion/outbound_call.rb +2 -0
- data/lib/adhearsion/plugin.rb +9 -7
- data/lib/adhearsion/plugin/collection.rb +3 -1
- data/lib/adhearsion/plugin/initializer.rb +3 -1
- data/lib/adhearsion/process.rb +8 -2
- data/lib/adhearsion/punchblock_plugin.rb +3 -1
- data/lib/adhearsion/punchblock_plugin/initializer.rb +34 -11
- data/lib/adhearsion/router.rb +4 -2
- data/lib/adhearsion/router/route.rb +2 -0
- data/lib/adhearsion/script_ahn_loader.rb +2 -0
- data/lib/adhearsion/tasks.rb +2 -0
- data/lib/adhearsion/tasks/configuration.rb +2 -0
- data/lib/adhearsion/tasks/debugging.rb +8 -0
- data/lib/adhearsion/tasks/environment.rb +2 -0
- data/lib/adhearsion/tasks/plugins.rb +2 -0
- data/lib/adhearsion/tasks/testing.rb +2 -0
- data/lib/adhearsion/version.rb +3 -1
- data/pre-commit +2 -0
- data/spec/adhearsion/call_controller/dial_spec.rb +114 -25
- data/spec/adhearsion/call_controller/input_spec.rb +192 -169
- data/spec/adhearsion/call_controller/output_spec.rb +26 -12
- data/spec/adhearsion/call_controller/record_spec.rb +29 -77
- data/spec/adhearsion/call_controller/utility_spec.rb +69 -0
- data/spec/adhearsion/call_controller_spec.rb +90 -15
- data/spec/adhearsion/call_spec.rb +92 -24
- data/spec/adhearsion/calls_spec.rb +9 -7
- data/spec/adhearsion/configuration_spec.rb +58 -56
- data/spec/adhearsion/console_spec.rb +4 -2
- data/spec/adhearsion/events_spec.rb +9 -7
- data/spec/adhearsion/generators_spec.rb +3 -1
- data/spec/adhearsion/initializer_spec.rb +16 -14
- data/spec/adhearsion/logging_spec.rb +11 -9
- data/spec/adhearsion/menu_dsl/calculated_match_collection_spec.rb +6 -4
- data/spec/adhearsion/menu_dsl/calculated_match_spec.rb +6 -4
- data/spec/adhearsion/menu_dsl/fixnum_match_calculator_spec.rb +3 -1
- data/spec/adhearsion/menu_dsl/match_calculator_spec.rb +2 -0
- data/spec/adhearsion/menu_dsl/menu_builder_spec.rb +42 -11
- data/spec/adhearsion/menu_dsl/menu_spec.rb +197 -36
- data/spec/adhearsion/menu_dsl/range_match_calculator_spec.rb +4 -2
- data/spec/adhearsion/menu_dsl/string_match_calculator_spec.rb +5 -3
- data/spec/adhearsion/outbound_call_spec.rb +7 -5
- data/spec/adhearsion/plugin_spec.rb +19 -15
- data/spec/adhearsion/process_spec.rb +12 -7
- data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +35 -15
- data/spec/adhearsion/punchblock_plugin_spec.rb +4 -1
- data/spec/adhearsion/router/route_spec.rb +8 -6
- data/spec/adhearsion/router_spec.rb +12 -10
- data/spec/adhearsion_spec.rb +13 -2
- data/spec/capture_warnings.rb +33 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/call_controller_test_helpers.rb +2 -4
- data/spec/support/initializer_stubs.rb +8 -5
- data/spec/support/logging_helpers.rb +2 -0
- data/spec/support/punchblock_mocks.rb +2 -0
- metadata +84 -71
- data/EVENTS +0 -11
- data/lib/adhearsion/call_controller/menu.rb +0 -124
- data/lib/adhearsion/foundation/all.rb +0 -8
- data/spec/adhearsion/call_controller/menu_spec.rb +0 -120
- data/spec/adhearsion/menu_dsl_spec.rb +0 -12
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -11,16 +13,16 @@ module Adhearsion
|
|
11
13
|
end
|
12
14
|
|
13
15
|
it 'can create a call and add it to the active calls' do
|
14
|
-
Adhearsion.active_calls.any?.should == false
|
16
|
+
Adhearsion.active_calls.any?.should be == false
|
15
17
|
call = Adhearsion.active_calls.from_offer new_offer
|
16
18
|
call.should be_a Adhearsion::Call
|
17
|
-
Adhearsion.active_calls.size.should == 1
|
19
|
+
Adhearsion.active_calls.size.should be == 1
|
18
20
|
end
|
19
21
|
|
20
22
|
it '#size should return the size of the collection' do
|
21
|
-
subject.size.should == 0
|
23
|
+
subject.size.should be == 0
|
22
24
|
subject << call
|
23
|
-
subject.size.should == 1
|
25
|
+
subject.size.should be == 1
|
24
26
|
end
|
25
27
|
|
26
28
|
it '#remove_inactive_call should delete the call in the Hash' do
|
@@ -30,7 +32,7 @@ module Adhearsion
|
|
30
32
|
|
31
33
|
deleted_call = calls[number_of_calls / 2]
|
32
34
|
subject.remove_inactive_call deleted_call
|
33
|
-
subject.size.should == number_of_calls - 1
|
35
|
+
subject.size.should be == number_of_calls - 1
|
34
36
|
end
|
35
37
|
|
36
38
|
it '#find should pull the Call from the Hash using the id' do
|
@@ -45,13 +47,13 @@ module Adhearsion
|
|
45
47
|
tagged_call = calls.last
|
46
48
|
tagged_call.tag :moderator
|
47
49
|
|
48
|
-
subject.with_tag(:moderator).should == [tagged_call]
|
50
|
+
subject.with_tag(:moderator).should be == [tagged_call]
|
49
51
|
end
|
50
52
|
|
51
53
|
describe "#<<" do
|
52
54
|
it "should allow chaining" do
|
53
55
|
subject << Call.new(new_offer) << Call.new(new_offer)
|
54
|
-
subject.size.should == 2
|
56
|
+
subject.size.should be == 2
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Adhearsion::Configuration do
|
@@ -20,18 +22,18 @@ describe Adhearsion::Configuration do
|
|
20
22
|
end
|
21
23
|
|
22
24
|
it "should initialize logging to level info" do
|
23
|
-
subject.platform.logging.level.should == :info
|
25
|
+
subject.platform.logging.level.should be == :info
|
24
26
|
end
|
25
27
|
|
26
28
|
it "should allow to update a config value" do
|
27
|
-
subject.platform.environment.should == :development
|
29
|
+
subject.platform.environment.should be == :development
|
28
30
|
subject.platform.environment = :production
|
29
|
-
subject.platform.environment.should == :production
|
31
|
+
subject.platform.environment.should be == :production
|
30
32
|
end
|
31
33
|
|
32
34
|
it "should allow to create new config values" do
|
33
35
|
subject.platform.bar = "foo"
|
34
|
-
subject.platform.bar.should == "foo"
|
36
|
+
subject.platform.bar.should be == "foo"
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
@@ -44,11 +46,11 @@ describe Adhearsion::Configuration do
|
|
44
46
|
end
|
45
47
|
|
46
48
|
it "should return the root value" do
|
47
|
-
subject.platform.root.should == "foo"
|
49
|
+
subject.platform.root.should be == "foo"
|
48
50
|
end
|
49
51
|
|
50
52
|
it "should return the environment value" do
|
51
|
-
subject.platform.environment.should == :development
|
53
|
+
subject.platform.environment.should be == :development
|
52
54
|
end
|
53
55
|
|
54
56
|
it "should return a description for the platform configuration" do
|
@@ -56,14 +58,14 @@ describe Adhearsion::Configuration do
|
|
56
58
|
end
|
57
59
|
|
58
60
|
it "should allow to update a config value" do
|
59
|
-
subject.platform.environment.should == :development
|
61
|
+
subject.platform.environment.should be == :development
|
60
62
|
subject.platform.environment = :production
|
61
|
-
subject.platform.environment.should == :production
|
63
|
+
subject.platform.environment.should be == :production
|
62
64
|
end
|
63
65
|
|
64
66
|
it "should allow to create new config values" do
|
65
67
|
subject.platform.bar = "bazz"
|
66
|
-
subject.platform.bar.should == "bazz"
|
68
|
+
subject.platform.bar.should be == "bazz"
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -71,7 +73,7 @@ describe Adhearsion::Configuration do
|
|
71
73
|
it "should raise a ConfigurationError" do
|
72
74
|
lambda {
|
73
75
|
Adhearsion.config.foo.bar = "bazz"
|
74
|
-
}.should raise_error Adhearsion::ConfigurationError, "Invalid plugin foo"
|
76
|
+
}.should raise_error Adhearsion::Configuration::ConfigurationError, "Invalid plugin foo"
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
@@ -87,7 +89,7 @@ describe Adhearsion::Configuration do
|
|
87
89
|
end
|
88
90
|
|
89
91
|
it "should allow to retrieve any platform configuration value" do
|
90
|
-
subject.environment.should == :development
|
92
|
+
subject.environment.should be == :development
|
91
93
|
end
|
92
94
|
|
93
95
|
describe "if configuration has a named environment" do
|
@@ -104,8 +106,8 @@ describe Adhearsion::Configuration do
|
|
104
106
|
end
|
105
107
|
|
106
108
|
let :config_object do
|
107
|
-
|
108
|
-
my_level
|
109
|
+
config_obj do
|
110
|
+
my_level(-1, :desc => "An index to check the environment value is being retrieved")
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
@@ -126,13 +128,13 @@ describe Adhearsion::Configuration do
|
|
126
128
|
end
|
127
129
|
|
128
130
|
it "should return by default the development value" do
|
129
|
-
subject.platform.my_level.should == 1
|
131
|
+
subject.platform.my_level.should be == 1
|
130
132
|
end
|
131
133
|
|
132
134
|
[:staging, :production, :test].each do |env|
|
133
135
|
it "should return the #{env.to_s} value when environment set to #{env.to_s}" do
|
134
136
|
config_object.platform.environment = env
|
135
|
-
subject.platform.my_level.should == env_values[env]
|
137
|
+
subject.platform.my_level.should be == env_values[env]
|
136
138
|
end
|
137
139
|
end
|
138
140
|
end
|
@@ -146,7 +148,7 @@ describe Adhearsion::Configuration do
|
|
146
148
|
end
|
147
149
|
|
148
150
|
it "should return 'development' by default" do
|
149
|
-
Adhearsion.config.platform.environment.should == :development
|
151
|
+
Adhearsion.config.platform.environment.should be == :development
|
150
152
|
end
|
151
153
|
|
152
154
|
[:development, :production, :staging, :test].each do |env|
|
@@ -159,20 +161,20 @@ describe Adhearsion::Configuration do
|
|
159
161
|
[:production, :staging, :test].each do |env|
|
160
162
|
it "should override the environment value with #{env.to_s} when set in ENV value" do
|
161
163
|
ENV['AHN_ENV'] = env.to_s
|
162
|
-
Adhearsion.config.platform.environment.should == env
|
164
|
+
Adhearsion.config.platform.environment.should be == env
|
163
165
|
end
|
164
166
|
end
|
165
167
|
end
|
166
168
|
|
167
169
|
it "should not override the default environment with the ENV value if valid" do
|
168
170
|
ENV['AHN_ENV'] = "invalid_value"
|
169
|
-
Adhearsion.config.platform.environment.should == :development
|
171
|
+
Adhearsion.config.platform.environment.should be == :development
|
170
172
|
end
|
171
173
|
|
172
174
|
it "should allow to add a new environment" do
|
173
|
-
Adhearsion.config.valid_environment?(:another_environment).should == false
|
175
|
+
Adhearsion.config.valid_environment?(:another_environment).should be == false
|
174
176
|
Adhearsion.environments << :another_environment
|
175
|
-
Adhearsion.config.valid_environment?(:another_environment).should == true
|
177
|
+
Adhearsion.config.valid_environment?(:another_environment).should be == true
|
176
178
|
end
|
177
179
|
|
178
180
|
end
|
@@ -186,16 +188,16 @@ describe Adhearsion::Configuration do
|
|
186
188
|
|
187
189
|
it "should retrieve a string with the platform configuration" do
|
188
190
|
desc = subject.description :platform, :show_values => false
|
189
|
-
desc.length.should > 0
|
190
|
-
desc.should match
|
191
|
-
desc.should match
|
191
|
+
desc.length.should be > 0
|
192
|
+
desc.should match(/^.*environment.*$/)
|
193
|
+
desc.should match(/^.*root.*$/)
|
192
194
|
end
|
193
195
|
|
194
196
|
it "should retrieve a string with the platform configuration and values" do
|
195
197
|
desc = subject.description :platform
|
196
|
-
desc.length.should > 0
|
197
|
-
desc.should match
|
198
|
-
desc.should match
|
198
|
+
desc.length.should be > 0
|
199
|
+
desc.should match(/^.*environment.*:development.*$/)
|
200
|
+
desc.should match(/^.*root.*$/)
|
199
201
|
end
|
200
202
|
|
201
203
|
describe "if there are plugins installed" do
|
@@ -216,9 +218,9 @@ describe Adhearsion::Configuration do
|
|
216
218
|
subject { Adhearsion.config.my_plugin }
|
217
219
|
|
218
220
|
it "should have the correct values" do
|
219
|
-
subject[:name].should == 'user'
|
220
|
-
subject[:password].should == 'password'
|
221
|
-
subject[:host].should == 'localhost'
|
221
|
+
subject[:name].should be == 'user'
|
222
|
+
subject[:password].should be == 'password'
|
223
|
+
subject[:host].should be == 'localhost'
|
222
224
|
end
|
223
225
|
end
|
224
226
|
|
@@ -226,9 +228,9 @@ describe Adhearsion::Configuration do
|
|
226
228
|
subject { Adhearsion.config[:my_plugin] }
|
227
229
|
|
228
230
|
it "should have the correct values" do
|
229
|
-
subject[:name].should == 'user'
|
230
|
-
subject[:password].should == 'password'
|
231
|
-
subject[:host].should == 'localhost'
|
231
|
+
subject[:name].should be == 'user'
|
232
|
+
subject[:password].should be == 'password'
|
233
|
+
subject[:host].should be == 'localhost'
|
232
234
|
end
|
233
235
|
end
|
234
236
|
|
@@ -253,13 +255,13 @@ describe Adhearsion::Configuration do
|
|
253
255
|
|
254
256
|
it "should return the development value by default" do
|
255
257
|
Adhearsion.config # initialize
|
256
|
-
subject.name.should == "development"
|
258
|
+
subject.name.should be == "development"
|
257
259
|
end
|
258
260
|
|
259
261
|
[:development, :staging, :production, :test].each do |env|
|
260
262
|
it "should return the #{env.to_s} value when environment is set to #{env.to_s}" do
|
261
263
|
Adhearsion.config.platform.environment = env
|
262
|
-
subject.name.should == env.to_s
|
264
|
+
subject.name.should be == env.to_s
|
263
265
|
end
|
264
266
|
end
|
265
267
|
end
|
@@ -267,40 +269,40 @@ describe Adhearsion::Configuration do
|
|
267
269
|
|
268
270
|
it "should retrieve a valid plugin description" do
|
269
271
|
desc = subject.description :my_plugin
|
270
|
-
desc.length.should > 0
|
271
|
-
desc.should match
|
272
|
-
desc.should match
|
273
|
-
desc.should match
|
272
|
+
desc.length.should be > 0
|
273
|
+
desc.should match(/^.*name.*user.*$/)
|
274
|
+
desc.should match(/^.*password.*password.*$/)
|
275
|
+
desc.should match(/^.*host.*localhost.*$/)
|
274
276
|
end
|
275
277
|
|
276
278
|
it "should retrieve a valid plugin description with no values" do
|
277
279
|
desc = subject.description :my_plugin, :show_values => false
|
278
|
-
desc.length.should > 0
|
279
|
-
desc.should match
|
280
|
-
desc.should match
|
281
|
-
desc.should match
|
280
|
+
desc.length.should be > 0
|
281
|
+
desc.should match(/^.*name.*$/)
|
282
|
+
desc.should match(/^.*password.*$/)
|
283
|
+
desc.should match(/^.*host.*$/)
|
282
284
|
end
|
283
285
|
|
284
286
|
it "should retrieve both platform and plugin configuration" do
|
285
287
|
desc = subject.description :all
|
286
|
-
desc.length.should > 0
|
287
|
-
desc.should match
|
288
|
-
desc.should match
|
289
|
-
desc.should match
|
290
|
-
desc.should match
|
291
|
-
desc.should match
|
288
|
+
desc.length.should be > 0
|
289
|
+
desc.should match(/^.*environment.*:development.*$/)
|
290
|
+
desc.should match(/^.*root.*$/)
|
291
|
+
desc.should match(/^.*name.*user.*$/)
|
292
|
+
desc.should match(/^.*password.*password.*$/)
|
293
|
+
desc.should match(/^.*host.*localhost.*$/)
|
292
294
|
end
|
293
295
|
|
294
296
|
it "should retrieve both platform and plugin configuration with no values" do
|
295
297
|
desc = subject.description :all, :show_values => false
|
296
|
-
desc.length.should > 0
|
297
|
-
desc.should match
|
298
|
-
desc.should match
|
299
|
-
desc.should match
|
300
|
-
desc.should match
|
301
|
-
desc.should match
|
302
|
-
desc.should match
|
303
|
-
desc.should match
|
298
|
+
desc.length.should be > 0
|
299
|
+
desc.should match(/^.*Configuration for platform.*$/)
|
300
|
+
desc.should match(/^.*environment.*$/)
|
301
|
+
desc.should match(/^.*root.*$/)
|
302
|
+
desc.should match(/^.*Configuration for my_plugin.*$/)
|
303
|
+
desc.should match(/^.*name.*$/)
|
304
|
+
desc.should match(/^.*password.*$/)
|
305
|
+
desc.should match(/^.*host.*$/)
|
304
306
|
end
|
305
307
|
end
|
306
308
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -37,7 +39,7 @@ module Adhearsion
|
|
37
39
|
context "without a value" do
|
38
40
|
it "should return the current level as a symbol" do
|
39
41
|
Adhearsion::Logging.level = :fatal
|
40
|
-
Console.log_level.should == :fatal
|
42
|
+
Console.log_level.should be == :fatal
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -123,7 +125,7 @@ module Adhearsion
|
|
123
125
|
|
124
126
|
context "if an active call with that ID does not exist" do
|
125
127
|
it "should log an error explaining that the call does not exist" do
|
126
|
-
flexmock(Console.logger).should_receive(:error).once.with
|
128
|
+
flexmock(Console.logger).should_receive(:error).once.with(/does not exist/)
|
127
129
|
flexmock(Console.instance).should_receive(:interact_with_call).never
|
128
130
|
Console.take call_id
|
129
131
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -28,8 +30,8 @@ module Adhearsion
|
|
28
30
|
Events.trigger :event, :foo
|
29
31
|
|
30
32
|
latch.wait(2).should be_true
|
31
|
-
t.should == :event
|
32
|
-
o.should == :foo
|
33
|
+
t.should be == :event
|
34
|
+
o.should be == :foo
|
33
35
|
end
|
34
36
|
|
35
37
|
it "should allow executing events immediately" do
|
@@ -44,8 +46,8 @@ module Adhearsion
|
|
44
46
|
|
45
47
|
Events.trigger_immediately :event, :foo
|
46
48
|
|
47
|
-
t.should == :event
|
48
|
-
o.should == :foo
|
49
|
+
t.should be == :event
|
50
|
+
o.should be == :foo
|
49
51
|
end
|
50
52
|
|
51
53
|
it "should handle events using registered guarded handlers" do
|
@@ -57,7 +59,7 @@ module Adhearsion
|
|
57
59
|
|
58
60
|
Events.trigger_immediately :event, EventClass.new
|
59
61
|
|
60
|
-
result.should == :foo
|
62
|
+
result.should be == :foo
|
61
63
|
|
62
64
|
Events.clear_handlers :event, EventClass
|
63
65
|
end
|
@@ -86,7 +88,7 @@ module Adhearsion
|
|
86
88
|
|
87
89
|
Events.trigger_immediately :event, EventClass.new
|
88
90
|
|
89
|
-
result.should == :bar
|
91
|
+
result.should be == :bar
|
90
92
|
|
91
93
|
Events.clear_handlers :event, EventClass
|
92
94
|
end
|
@@ -102,7 +104,7 @@ module Adhearsion
|
|
102
104
|
|
103
105
|
Events.trigger_immediately :event
|
104
106
|
|
105
|
-
result.should == :foo
|
107
|
+
result.should be == :foo
|
106
108
|
|
107
109
|
Events.clear_handlers :event
|
108
110
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'adhearsion/generators'
|
3
5
|
|
@@ -10,7 +12,7 @@ module Adhearsion
|
|
10
12
|
DummyGenerator = Class.new
|
11
13
|
|
12
14
|
Generators.add_generator generator_key, DummyGenerator
|
13
|
-
Generators.mappings[generator_key].should == DummyGenerator
|
15
|
+
Generators.mappings[generator_key].should be == DummyGenerator
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Adhearsion::Initializer do
|
@@ -36,7 +38,7 @@ describe Adhearsion::Initializer do
|
|
36
38
|
stub_behavior_for_initializer_with_no_path_changing_behavior do
|
37
39
|
flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
|
38
40
|
ahn = Adhearsion::Initializer.start :pid_file => true
|
39
|
-
ahn.pid_file[0, path.length].should == path
|
41
|
+
ahn.pid_file[0, path.length].should be == path
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -51,7 +53,7 @@ describe Adhearsion::Initializer do
|
|
51
53
|
stub_behavior_for_initializer_with_no_path_changing_behavior do
|
52
54
|
flexmock(File).should_receive(:open).once.with(File.join(path, 'adhearsion.pid'), 'w', Proc)
|
53
55
|
ahn = Adhearsion::Initializer.start :mode => :daemon
|
54
|
-
ahn.pid_file[0, path.size].should == path
|
56
|
+
ahn.pid_file[0, path.size].should be == path
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
@@ -66,7 +68,7 @@ describe Adhearsion::Initializer do
|
|
66
68
|
random_file = "/tmp/AHN_TEST_#{rand 100000}.pid"
|
67
69
|
stub_behavior_for_initializer_with_no_path_changing_behavior do
|
68
70
|
ahn = Adhearsion::Initializer.start :pid_file => random_file
|
69
|
-
ahn.pid_file.should == random_file
|
71
|
+
ahn.pid_file.should be == random_file
|
70
72
|
File.exists?(random_file).should be true
|
71
73
|
File.delete random_file
|
72
74
|
end
|
@@ -76,7 +78,7 @@ describe Adhearsion::Initializer do
|
|
76
78
|
stub_behavior_for_initializer_with_no_path_changing_behavior do
|
77
79
|
flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
|
78
80
|
ahn = Adhearsion::Initializer.start :pid_file => true
|
79
|
-
ahn.resolve_log_file_path.should == path + Adhearsion.config.platform.logging.outputters[0]
|
81
|
+
ahn.resolve_log_file_path.should be == path + Adhearsion.config.platform.logging.outputters[0]
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
@@ -85,7 +87,7 @@ describe Adhearsion::Initializer do
|
|
85
87
|
stub_behavior_for_initializer_with_no_path_changing_behavior do
|
86
88
|
flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
|
87
89
|
ahn = Adhearsion::Initializer.start :pid_file => true
|
88
|
-
ahn.resolve_log_file_path.should == path + Adhearsion.config.platform.logging.outputters[0]
|
90
|
+
ahn.resolve_log_file_path.should be == path + Adhearsion.config.platform.logging.outputters[0]
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
@@ -120,7 +122,7 @@ describe Adhearsion::Initializer do
|
|
120
122
|
end
|
121
123
|
|
122
124
|
it "should set the adhearsion proc name" do
|
123
|
-
|
125
|
+
stub_behavior_for_initializer_with_no_path_changing_behavior do
|
124
126
|
flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
|
125
127
|
flexmock(Adhearsion::LinuxProcName).should_receive(:set_proc_name).with(Adhearsion.config.platform.process_name)
|
126
128
|
Adhearsion::Initializer.start :pid_file => true
|
@@ -128,10 +130,10 @@ describe Adhearsion::Initializer do
|
|
128
130
|
end
|
129
131
|
|
130
132
|
it "should update the adhearsion proc name" do
|
131
|
-
|
133
|
+
stub_behavior_for_initializer_with_no_path_changing_behavior do
|
132
134
|
Adhearsion::Initializer.start :pid_file => true
|
133
135
|
end
|
134
|
-
$0.should == Adhearsion.config.platform.process_name
|
136
|
+
$0.should be == Adhearsion.config.platform.process_name
|
135
137
|
end
|
136
138
|
end
|
137
139
|
|
@@ -171,12 +173,12 @@ describe Adhearsion::Initializer do
|
|
171
173
|
|
172
174
|
it "should return false if folder does not exist" do
|
173
175
|
Adhearsion.config.platform.lib = "my_random_lib_directory"
|
174
|
-
Adhearsion::Initializer.new.load_lib_folder.should == false
|
176
|
+
Adhearsion::Initializer.new.load_lib_folder.should be == false
|
175
177
|
end
|
176
178
|
|
177
179
|
it "should return false and not load any file if config folder is set to nil" do
|
178
180
|
Adhearsion.config.platform.lib = nil
|
179
|
-
Adhearsion::Initializer.new.load_lib_folder.should == false
|
181
|
+
Adhearsion::Initializer.new.load_lib_folder.should be == false
|
180
182
|
end
|
181
183
|
|
182
184
|
it "should load the contents of the preconfigured directory" do
|
@@ -217,7 +219,7 @@ describe "Updating RAILS_ENV variable" do
|
|
217
219
|
ahn = Adhearsion::Initializer.start
|
218
220
|
end
|
219
221
|
ahn.update_rails_env_var
|
220
|
-
ENV['RAILS_ENV'].should == env.to_s
|
222
|
+
ENV['RAILS_ENV'].should be == env.to_s
|
221
223
|
end
|
222
224
|
end
|
223
225
|
end
|
@@ -235,7 +237,7 @@ describe "Updating RAILS_ENV variable" do
|
|
235
237
|
ahn = Adhearsion::Initializer.start
|
236
238
|
end
|
237
239
|
ahn.update_rails_env_var
|
238
|
-
ENV['RAILS_ENV'].should == "test"
|
240
|
+
ENV['RAILS_ENV'].should be == "test"
|
239
241
|
end
|
240
242
|
end
|
241
243
|
|
@@ -246,7 +248,7 @@ describe "Updating RAILS_ENV variable" do
|
|
246
248
|
ahn = Adhearsion::Initializer.start
|
247
249
|
end
|
248
250
|
ahn.update_rails_env_var
|
249
|
-
ENV['RAILS_ENV'].should == "test"
|
251
|
+
ENV['RAILS_ENV'].should be == "test"
|
250
252
|
end
|
251
253
|
end
|
252
254
|
end
|
@@ -262,7 +264,7 @@ describe "Updating RAILS_ENV variable" do
|
|
262
264
|
ahn = Adhearsion::Initializer.start
|
263
265
|
end
|
264
266
|
ahn.update_rails_env_var
|
265
|
-
ENV['RAILS_ENV'].should == "production"
|
267
|
+
ENV['RAILS_ENV'].should be == "production"
|
266
268
|
end
|
267
269
|
end
|
268
270
|
|