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
|
@@ -8,8 +10,8 @@ module Adhearsion
|
|
8
10
|
digits_that_begin_with_eleven = [110..119, 1100..1111].map { |x| Array(x) }.flatten
|
9
11
|
calculator = RangeMatchCalculator.new 11..1111, :match_payload_doesnt_matter
|
10
12
|
match = calculator.match 11
|
11
|
-
match.exact_matches.should == [11]
|
12
|
-
match.potential_matches.should == digits_that_begin_with_eleven
|
13
|
+
match.exact_matches.should be == [11]
|
14
|
+
match.potential_matches.should be == digits_that_begin_with_eleven
|
13
15
|
end
|
14
16
|
|
15
17
|
it "return values of #match should be an instance of CalculatedMatch" do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -13,12 +15,12 @@ module Adhearsion
|
|
13
15
|
match_case = calculator.match str[0,2]
|
14
16
|
match_case.exact_match?.should_not be true
|
15
17
|
match_case.potential_match?.should be true
|
16
|
-
match_case.potential_matches.should == [str]
|
18
|
+
match_case.potential_matches.should be == [str]
|
17
19
|
|
18
20
|
match_case = calculator.match str
|
19
21
|
match_case.exact_match?.should be true
|
20
22
|
match_case.potential_match?.should_not be true
|
21
|
-
match_case.exact_matches.should == [str]
|
23
|
+
match_case.exact_matches.should be == [str]
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
@@ -28,7 +30,7 @@ module Adhearsion
|
|
28
30
|
match_case = calculator.match special_digit
|
29
31
|
match_case.potential_match?.should_not be true
|
30
32
|
match_case.exact_match?.should be true
|
31
|
-
match_case.exact_matches.first.should == special_digit
|
33
|
+
match_case.exact_matches.first.should be == special_digit
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -5,7 +7,7 @@ module Adhearsion
|
|
5
7
|
it { should be_a Call }
|
6
8
|
|
7
9
|
its(:id) { should be_nil }
|
8
|
-
its(:variables) { should == {} }
|
10
|
+
its(:variables) { should be == {} }
|
9
11
|
|
10
12
|
let(:mock_client) { flexmock 'Punchblock Client' }
|
11
13
|
|
@@ -79,22 +81,22 @@ module Adhearsion
|
|
79
81
|
|
80
82
|
it "should set the dial command" do
|
81
83
|
subject.dial to, :from => from
|
82
|
-
subject.dial_command.should == expected_dial_command
|
84
|
+
subject.dial_command.should be == expected_dial_command
|
83
85
|
end
|
84
86
|
|
85
87
|
it "should set the call ID from the dial command" do
|
86
88
|
subject.dial to, :from => from
|
87
|
-
subject.id.should == call_id
|
89
|
+
subject.id.should be == call_id
|
88
90
|
end
|
89
91
|
|
90
92
|
it "should set the to from the dial command" do
|
91
93
|
subject.dial to, :from => from
|
92
|
-
subject.to.should == to
|
94
|
+
subject.to.should be == to
|
93
95
|
end
|
94
96
|
|
95
97
|
it "should set the 'from' from the dial command" do
|
96
98
|
subject.dial to, :from => from
|
97
|
-
subject.from.should == from
|
99
|
+
subject.from.should be == from
|
98
100
|
end
|
99
101
|
|
100
102
|
it "should add the call to the active calls registry" do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
include InitializerStubs
|
@@ -15,12 +17,12 @@ describe Adhearsion::Plugin do
|
|
15
17
|
|
16
18
|
it "should provide the plugin name in a plugin class" do
|
17
19
|
::FooBar = Class.new Adhearsion::Plugin
|
18
|
-
::FooBar.plugin_name.should == "foo_bar"
|
20
|
+
::FooBar.plugin_name.should be == "foo_bar"
|
19
21
|
end
|
20
22
|
|
21
23
|
it "should provide the plugin name in a plugin instance" do
|
22
24
|
::FooBar = Class.new Adhearsion::Plugin
|
23
|
-
::FooBar.new.plugin_name.should == "foo_bar"
|
25
|
+
::FooBar.new.plugin_name.should be == "foo_bar"
|
24
26
|
end
|
25
27
|
|
26
28
|
it "should provide a setter for plugin name" do
|
@@ -28,7 +30,7 @@ describe Adhearsion::Plugin do
|
|
28
30
|
self.plugin_name = "bar_foo"
|
29
31
|
end
|
30
32
|
|
31
|
-
::FooBar.plugin_name.should == "bar_foo"
|
33
|
+
::FooBar.plugin_name.should be == "bar_foo"
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -47,7 +49,7 @@ describe Adhearsion::Plugin do
|
|
47
49
|
end
|
48
50
|
}
|
49
51
|
|
50
|
-
its(:plugin_name) { should == :bar_foo }
|
52
|
+
its(:plugin_name) { should be == :bar_foo }
|
51
53
|
|
52
54
|
its(:config) { should be_instance_of Loquacious::Configuration }
|
53
55
|
|
@@ -56,9 +58,9 @@ describe Adhearsion::Plugin do
|
|
56
58
|
subject.config.should respond_to value
|
57
59
|
end
|
58
60
|
|
59
|
-
subject.config.name.should == "user"
|
60
|
-
subject.config.password.should == "password"
|
61
|
-
subject.config.host.should == "localhost"
|
61
|
+
subject.config.name.should be == "user"
|
62
|
+
subject.config.password.should be == "password"
|
63
|
+
subject.config.host.should be == "localhost"
|
62
64
|
end
|
63
65
|
|
64
66
|
it "should return a description of configuration options" do
|
@@ -68,7 +70,7 @@ describe Adhearsion::Plugin do
|
|
68
70
|
describe "while updating config values" do
|
69
71
|
it "should return the updated value" do
|
70
72
|
subject.config.name = "usera"
|
71
|
-
subject.config.name.should == "usera"
|
73
|
+
subject.config.name.should be == "usera"
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
@@ -105,7 +107,7 @@ describe Adhearsion::Plugin do
|
|
105
107
|
end
|
106
108
|
|
107
109
|
describe "Adhearsion::Plugin.init_plugins" do
|
108
|
-
before do
|
110
|
+
before(:all) do
|
109
111
|
Adhearsion::Plugin.class_eval do
|
110
112
|
def self.reset_methods_scope
|
111
113
|
@methods_scope = Hash.new { |hash, key| hash[key] = Module.new }
|
@@ -115,7 +117,9 @@ describe Adhearsion::Plugin do
|
|
115
117
|
@subclasses = nil
|
116
118
|
end
|
117
119
|
end
|
120
|
+
end
|
118
121
|
|
122
|
+
before do
|
119
123
|
Adhearsion::Plugin.reset_methods_scope
|
120
124
|
Adhearsion::Plugin.reset_subclasses
|
121
125
|
end
|
@@ -340,29 +344,29 @@ describe Adhearsion::Plugin do
|
|
340
344
|
subject.should be_instance_of Array
|
341
345
|
end
|
342
346
|
|
343
|
-
its(:length) { should == 0 }
|
347
|
+
its(:length) { should be == 0 }
|
344
348
|
|
345
349
|
it "should not load a new task when there is no block in the method call" do
|
346
|
-
subject.length.should == 0
|
350
|
+
subject.length.should be == 0
|
347
351
|
FooBar = Class.new Adhearsion::Plugin do
|
348
352
|
tasks
|
349
353
|
end
|
350
354
|
|
351
|
-
subject.length.should == 0
|
355
|
+
subject.length.should be == 0
|
352
356
|
end
|
353
357
|
|
354
358
|
it "should load a new task when there is a block in the method call" do
|
355
|
-
subject.length.should == 0
|
359
|
+
subject.length.should be == 0
|
356
360
|
FooBar = Class.new Adhearsion::Plugin do
|
357
361
|
tasks do
|
358
362
|
puts "foo bar"
|
359
363
|
end
|
360
364
|
end
|
361
|
-
Adhearsion::Plugin.tasks.length.should == 1
|
365
|
+
Adhearsion::Plugin.tasks.length.should be == 1
|
362
366
|
end
|
363
367
|
|
364
368
|
it "should execute the tasks blocks while loading rake tasks" do
|
365
|
-
subject.length.should == 0
|
369
|
+
subject.length.should be == 0
|
366
370
|
FooBar = Class.new Adhearsion::Plugin do
|
367
371
|
tasks do
|
368
372
|
FooBar.foo
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -11,7 +13,8 @@ module Adhearsion
|
|
11
13
|
end
|
12
14
|
|
13
15
|
it 'should trigger :stop_requested events on #shutdown' do
|
14
|
-
flexmock(Events).should_receive(:trigger_immediately).once.with(:stop_requested)
|
16
|
+
flexmock(Events).should_receive(:trigger_immediately).once.with(:stop_requested).ordered
|
17
|
+
flexmock(Events).should_receive(:trigger_immediately).once.with(:shutdown).ordered
|
15
18
|
Adhearsion::Process.booted
|
16
19
|
Adhearsion::Process.shutdown
|
17
20
|
end
|
@@ -56,15 +59,17 @@ module Adhearsion
|
|
56
59
|
end
|
57
60
|
|
58
61
|
it "should trigger shutdown handlers synchronously" do
|
59
|
-
|
62
|
+
foo = lambda { |b| b }
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
flexmock(foo).should_receive(:[]).once.with(:a).ordered
|
65
|
+
flexmock(foo).should_receive(:[]).once.with(:b).ordered
|
66
|
+
flexmock(foo).should_receive(:[]).once.with(:c).ordered
|
64
67
|
|
65
|
-
|
68
|
+
Events.shutdown { sleep 2; foo[:a] }
|
69
|
+
Events.shutdown { sleep 1; foo[:b] }
|
70
|
+
Events.shutdown { foo[:c] }
|
66
71
|
|
67
|
-
|
72
|
+
Adhearsion::Process.final_shutdown
|
68
73
|
end
|
69
74
|
|
70
75
|
it "should stop the console" do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -57,11 +59,11 @@ module Adhearsion
|
|
57
59
|
subject { initialize_punchblock }
|
58
60
|
|
59
61
|
it "should set properly the username value" do
|
60
|
-
subject.username.should == 'usera@127.0.0.1'
|
62
|
+
subject.username.should be == 'usera@127.0.0.1'
|
61
63
|
end
|
62
64
|
|
63
65
|
it "should set properly the password value" do
|
64
|
-
subject.password.should == '1'
|
66
|
+
subject.password.should be == '1'
|
65
67
|
end
|
66
68
|
|
67
69
|
it "should set properly the host value" do
|
@@ -85,15 +87,15 @@ module Adhearsion
|
|
85
87
|
end
|
86
88
|
|
87
89
|
it "should properly set the reconnect_attempts value" do
|
88
|
-
subject.reconnect_attempts.should == 1.0/0.0
|
90
|
+
subject.reconnect_attempts.should be == 1.0/0.0
|
89
91
|
end
|
90
92
|
|
91
93
|
it "should properly set the reconnect_timer value" do
|
92
|
-
subject.reconnect_timer.should == 5
|
94
|
+
subject.reconnect_timer.should be == 5
|
93
95
|
end
|
94
96
|
|
95
97
|
it "should properly set the media_engine value" do
|
96
|
-
subject.media_engine.should == nil
|
98
|
+
subject.media_engine.should be == nil
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
@@ -107,9 +109,9 @@ module Adhearsion
|
|
107
109
|
end
|
108
110
|
|
109
111
|
it "starts the client with any overridden settings" do
|
110
|
-
overrides = {:username => 'userb@127.0.0.1', :password => '123', :host => 'foo.bar.com', :port => 200, :connection_timeout => 20, :root_domain => 'foo.com', :calls_domain => 'call.foo.com', :mixers_domain => 'mixer.foo.com', :media_engine => :swift}
|
112
|
+
overrides = {:username => 'userb@127.0.0.1/foo', :password => '123', :host => 'foo.bar.com', :port => 200, :connection_timeout => 20, :root_domain => 'foo.com', :calls_domain => 'call.foo.com', :mixers_domain => 'mixer.foo.com', :media_engine => :swift}
|
111
113
|
|
112
|
-
flexmock(::Punchblock::Connection::XMPP).should_receive(:new).once.with(overrides
|
114
|
+
flexmock(::Punchblock::Connection::XMPP).should_receive(:new).once.with(overrides).and_return do
|
113
115
|
flexmock 'Client', :event_handler= => true
|
114
116
|
end
|
115
117
|
initialize_punchblock overrides
|
@@ -124,7 +126,7 @@ module Adhearsion
|
|
124
126
|
flexmock(mock_connection).should_receive(:run).once
|
125
127
|
t = Thread.new { Initializer.init; Initializer.run }
|
126
128
|
t.join 5
|
127
|
-
t.status.should == "sleep"
|
129
|
+
t.status.should be == "sleep"
|
128
130
|
Events.trigger_immediately :punchblock, ::Punchblock::Connection::Connected.new
|
129
131
|
t.join
|
130
132
|
end
|
@@ -147,17 +149,17 @@ module Adhearsion
|
|
147
149
|
|
148
150
|
it 'should reset the Adhearsion process state to "booting"' do
|
149
151
|
Adhearsion::Process.booted
|
150
|
-
Adhearsion::Process.state_name.should == :running
|
152
|
+
Adhearsion::Process.state_name.should be == :running
|
151
153
|
mock_client.should_receive(:run).and_raise ::Punchblock::DisconnectedError
|
152
|
-
|
153
|
-
|
154
|
+
flexmock(Adhearsion::Process).should_receive(:reset).at_least.once
|
155
|
+
Initializer.connect_to_server
|
154
156
|
end
|
155
157
|
|
156
158
|
it 'should retry the connection the specified number of times' do
|
157
159
|
Initializer.config.reconnect_attempts = 3
|
158
160
|
mock_client.should_receive(:run).and_raise ::Punchblock::DisconnectedError
|
159
|
-
|
160
|
-
Initializer.attempts.should == 3
|
161
|
+
Initializer.connect_to_server
|
162
|
+
Initializer.attempts.should be == 3
|
161
163
|
end
|
162
164
|
|
163
165
|
it 'should preserve a Punchblock::ProtocolError exception and give up' do
|
@@ -294,13 +296,31 @@ module Adhearsion
|
|
294
296
|
end
|
295
297
|
|
296
298
|
it "should set properly the username value" do
|
297
|
-
subject.username.should == 'userb@127.0.0.1'
|
299
|
+
subject.username.should be == 'userb@127.0.0.1'
|
298
300
|
end
|
299
301
|
|
300
302
|
it "should set properly the password value" do
|
301
|
-
subject.password.should == 'abc123'
|
303
|
+
subject.password.should be == 'abc123'
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
it "should allow easily registering handlers for AMI events" do
|
309
|
+
result = nil
|
310
|
+
ami_event = Punchblock::Event::Asterisk::AMI::Event.new :name => 'foobar'
|
311
|
+
latch = CountDownLatch.new 1
|
312
|
+
|
313
|
+
Events.draw do
|
314
|
+
ami :name => 'foobar' do |event|
|
315
|
+
result = event
|
316
|
+
latch.countdown!
|
302
317
|
end
|
303
318
|
end
|
319
|
+
|
320
|
+
Initializer.handle_event ami_event
|
321
|
+
|
322
|
+
latch.wait(1).should be true
|
323
|
+
result.should be ami_event
|
304
324
|
end
|
305
325
|
end
|
306
326
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -20,12 +22,13 @@ module Adhearsion
|
|
20
22
|
end
|
21
23
|
|
22
24
|
it "writes a command to the client" do
|
23
|
-
flexmock(PunchblockPlugin.client).should_receive(:execute_command).once.with(message)
|
25
|
+
flexmock(PunchblockPlugin.client).should_receive(:execute_command).once.with(message, :async => true)
|
24
26
|
PunchblockPlugin.execute_component message
|
25
27
|
end
|
26
28
|
|
27
29
|
it "blocks until a response is received" do
|
28
30
|
slow_command = Punchblock::Command::Dial.new
|
31
|
+
slow_command.request!
|
29
32
|
Thread.new do
|
30
33
|
sleep 0.5
|
31
34
|
slow_command.response = response
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Adhearsion
|
@@ -17,17 +19,17 @@ module Adhearsion
|
|
17
19
|
|
18
20
|
subject { Route.new name, target, *guards }
|
19
21
|
|
20
|
-
its(:name) { should == name }
|
21
|
-
its(:target) { should == target }
|
22
|
-
its(:guards) { should == guards }
|
22
|
+
its(:name) { should be == name }
|
23
|
+
its(:target) { should be == target }
|
24
|
+
its(:guards) { should be == guards }
|
23
25
|
end
|
24
26
|
|
25
27
|
describe "with a block target and guards" do
|
26
28
|
subject { Route.new(name, *guards) { :foo } }
|
27
29
|
|
28
|
-
its(:name) { should == name }
|
30
|
+
its(:name) { should be == name }
|
29
31
|
its(:target) { should be_a Proc }
|
30
|
-
its(:guards) { should == guards }
|
32
|
+
its(:guards) { should be == guards }
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -119,7 +121,7 @@ module Adhearsion
|
|
119
121
|
|
120
122
|
it "should instruct the call to use a CallController with the correct block" do
|
121
123
|
flexmock(call).should_receive(:execute_controller).once.with(CallController).and_return do |controller|
|
122
|
-
controller.block.call.should == :foobar
|
124
|
+
controller.block.call.should be == :foobar
|
123
125
|
end
|
124
126
|
route.dispatcher.call call
|
125
127
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
FooBarController = Class.new
|
@@ -39,16 +41,16 @@ module Adhearsion
|
|
39
41
|
end
|
40
42
|
|
41
43
|
it "should build up the routes with the correct data" do
|
42
|
-
subject[0].name.should == 'calls from fred'
|
43
|
-
subject[0].guards.should == [{:from => 'fred'}]
|
44
|
-
subject[0].target.should == FooBarController
|
44
|
+
subject[0].name.should be == 'calls from fred'
|
45
|
+
subject[0].guards.should be == [{:from => 'fred'}]
|
46
|
+
subject[0].target.should be == FooBarController
|
45
47
|
|
46
|
-
subject[1].name.should == 'calls from paul'
|
47
|
-
subject[1].guards.should == [{:from => 'paul'}]
|
48
|
+
subject[1].name.should be == 'calls from paul'
|
49
|
+
subject[1].guards.should be == [{:from => 'paul'}]
|
48
50
|
subject[1].target.should be_a Proc
|
49
51
|
|
50
|
-
subject[2].name.should == 'catchall'
|
51
|
-
subject[2].guards.should == []
|
52
|
+
subject[2].name.should be == 'catchall'
|
53
|
+
subject[2].guards.should be == []
|
52
54
|
subject[2].target.should be_a Proc
|
53
55
|
end
|
54
56
|
end
|
@@ -73,17 +75,17 @@ module Adhearsion
|
|
73
75
|
|
74
76
|
context 'with a call from fred' do
|
75
77
|
let(:call) { flexmock 'Adhearsion::Call', :from => 'fred' }
|
76
|
-
its(:name) { should == 'calls from fred' }
|
78
|
+
its(:name) { should be == 'calls from fred' }
|
77
79
|
end
|
78
80
|
|
79
81
|
context 'with a call from paul' do
|
80
82
|
let(:call) { flexmock 'Adhearsion::Call', :from => 'paul' }
|
81
|
-
its(:name) { should == 'calls from paul' }
|
83
|
+
its(:name) { should be == 'calls from paul' }
|
82
84
|
end
|
83
85
|
|
84
86
|
context 'with a call from frank' do
|
85
87
|
let(:call) { flexmock 'Adhearsion::Call', :from => 'frank' }
|
86
|
-
its(:name) { should == 'catchall' }
|
88
|
+
its(:name) { should be == 'catchall' }
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|