adhearsion 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +3 -0
  4. data/LICENSE +1 -1
  5. data/README.markdown +2 -2
  6. data/adhearsion.gemspec +0 -1
  7. data/lib/adhearsion/punchblock_plugin/initializer.rb +1 -1
  8. data/lib/adhearsion/version.rb +1 -1
  9. data/spec/adhearsion/call_controller/dial_spec.rb +56 -57
  10. data/spec/adhearsion/call_controller/input_spec.rb +11 -16
  11. data/spec/adhearsion/call_controller/menu_dsl/menu_builder_spec.rb +6 -6
  12. data/spec/adhearsion/call_controller/menu_dsl/menu_spec.rb +10 -10
  13. data/spec/adhearsion/call_controller/output/async_player_spec.rb +3 -3
  14. data/spec/adhearsion/call_controller/output/player_spec.rb +1 -1
  15. data/spec/adhearsion/call_controller/output_spec.rb +2 -7
  16. data/spec/adhearsion/call_controller/record_spec.rb +11 -18
  17. data/spec/adhearsion/call_controller_spec.rb +35 -35
  18. data/spec/adhearsion/call_spec.rb +49 -35
  19. data/spec/adhearsion/calls_spec.rb +2 -2
  20. data/spec/adhearsion/console_spec.rb +22 -23
  21. data/spec/adhearsion/events_spec.rb +3 -3
  22. data/spec/adhearsion/initializer_spec.rb +33 -35
  23. data/spec/adhearsion/logging_spec.rb +3 -3
  24. data/spec/adhearsion/outbound_call_spec.rb +21 -19
  25. data/spec/adhearsion/plugin_spec.rb +9 -11
  26. data/spec/adhearsion/process_spec.rb +15 -14
  27. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +37 -42
  28. data/spec/adhearsion/punchblock_plugin_spec.rb +2 -2
  29. data/spec/adhearsion/router/evented_route_spec.rb +1 -1
  30. data/spec/adhearsion/router/openended_route_spec.rb +5 -5
  31. data/spec/adhearsion/router/route_spec.rb +9 -9
  32. data/spec/adhearsion/router/unaccepting_route_spec.rb +6 -6
  33. data/spec/adhearsion/router_spec.rb +8 -8
  34. data/spec/adhearsion/statistics_spec.rb +1 -1
  35. data/spec/adhearsion_spec.rb +1 -1
  36. data/spec/spec_helper.rb +1 -2
  37. data/spec/support/call_controller_test_helpers.rb +11 -8
  38. data/spec/support/initializer_stubs.rb +1 -1
  39. data/spec/support/punchblock_mocks.rb +3 -2
  40. metadata +2 -16
@@ -125,8 +125,8 @@ module Adhearsion
125
125
 
126
126
  it "is sends a hangup command for the call" do
127
127
  call_id = call.id
128
- flexmock PunchblockPlugin, :client => flexmock('Client')
129
- flexmock(PunchblockPlugin.client).should_receive(:execute_command).once.with(Punchblock::Command::Hangup.new, :async => true, :call_id => call_id)
128
+ PunchblockPlugin.stub :client => mock('Client')
129
+ PunchblockPlugin.client.should_receive(:execute_command).once.with(Punchblock::Command::Hangup.new, :async => true, :call_id => call_id)
130
130
 
131
131
  subject << call
132
132
 
@@ -5,10 +5,9 @@ require 'spec_helper'
5
5
  module Adhearsion
6
6
  describe Console do
7
7
  before do
8
- flexmock Console.instance, :pry => nil
8
+ Console.instance.stub :pry => nil
9
9
  end
10
10
 
11
- include FlexMock::ArgumentTypes
12
11
  describe "providing hooks to include console functionality" do
13
12
  it "should allow mixing in a module globally on all CallController classes" do
14
13
  Console.mixin TestBiscuit
@@ -18,12 +17,12 @@ module Adhearsion
18
17
 
19
18
  describe 'testing for libedit vs. readline' do
20
19
  it 'should return true when detecting readline' do
21
- flexmock(Readline).should_receive(:emacs_editing_mode).once.and_return true
20
+ Readline.should_receive(:emacs_editing_mode).once.and_return true
22
21
  Console.libedit?.should be false
23
22
  end
24
23
 
25
24
  it 'should return false when detecting libedit' do
26
- flexmock(Readline).should_receive(:emacs_editing_mode).once.and_raise NotImplementedError
25
+ Readline.should_receive(:emacs_editing_mode).once.and_raise NotImplementedError
27
26
  Console.libedit?.should be true
28
27
  end
29
28
  end
@@ -31,7 +30,7 @@ module Adhearsion
31
30
  describe "#log_level" do
32
31
  context "with a value" do
33
32
  it "should set the log level via Adhearsion::Logging" do
34
- flexmock(Adhearsion::Logging).should_receive(:level=).once.with(:foo)
33
+ Adhearsion::Logging.should_receive(:level=).once.with(:foo)
35
34
  Console.log_level :foo
36
35
  end
37
36
  end
@@ -46,21 +45,21 @@ module Adhearsion
46
45
 
47
46
  describe "#silence!" do
48
47
  it "should delegate to Adhearsion::Logging" do
49
- flexmock(Adhearsion::Logging).should_receive(:silence!).once
48
+ Adhearsion::Logging.should_receive(:silence!).once
50
49
  Console.silence!
51
50
  end
52
51
  end
53
52
 
54
53
  describe "#unsilence!" do
55
54
  it "should delegate to Adhearsion::Logging" do
56
- flexmock(Adhearsion::Logging).should_receive(:unsilence!).once
55
+ Adhearsion::Logging.should_receive(:unsilence!).once
57
56
  Console.unsilence!
58
57
  end
59
58
  end
60
59
 
61
60
  describe "#shutdown!" do
62
61
  it "should tell the process to shutdown" do
63
- flexmock(Adhearsion::Process).should_receive(:shutdown!).once
62
+ Adhearsion::Process.should_receive(:shutdown!).once
64
63
  Console.shutdown!
65
64
  end
66
65
  end
@@ -71,12 +70,12 @@ module Adhearsion
71
70
 
72
71
  before do
73
72
  Adhearsion.active_calls.clear!
74
- flexmock(call).should_receive(:id => call_id)
73
+ call.stub(:id => call_id)
75
74
  end
76
75
 
77
76
  context "with a call" do
78
77
  it "should interact with the call" do
79
- flexmock(Console.instance).should_receive(:interact_with_call).once.with call
78
+ Console.instance.should_receive(:interact_with_call).once.with call
80
79
  Console.take call
81
80
  end
82
81
  end
@@ -88,7 +87,7 @@ module Adhearsion
88
87
  end
89
88
 
90
89
  it "should interact with the current call" do
91
- flexmock(Console.instance).should_receive(:interact_with_call).once.with call
90
+ Console.instance.should_receive(:interact_with_call).once.with call
92
91
  Console.take
93
92
  end
94
93
  end
@@ -97,15 +96,15 @@ module Adhearsion
97
96
  let(:call2) { Call.new }
98
97
 
99
98
  before do
100
- flexmock(call2).should_receive :id => rand.to_s
99
+ call2.stub :id => rand.to_s
101
100
  Adhearsion.active_calls << call << call2
102
101
  end
103
102
 
104
103
  it "should allow selection of the call to use" do
105
104
  mock_io = StringIO.new
106
105
  Console.input = mock_io
107
- flexmock(mock_io).should_receive(:gets).once.and_return "1\n"
108
- flexmock(Console.instance).should_receive(:interact_with_call).once.with call2
106
+ mock_io.should_receive(:gets).once.and_return "1\n"
107
+ Console.instance.should_receive(:interact_with_call).once.with call2
109
108
  Console.take
110
109
  end
111
110
  end
@@ -118,15 +117,15 @@ module Adhearsion
118
117
  end
119
118
 
120
119
  it "should interact with that call" do
121
- flexmock(Console.instance).should_receive(:interact_with_call).once.with call
120
+ Console.instance.should_receive(:interact_with_call).once.with call
122
121
  Console.take call_id
123
122
  end
124
123
  end
125
124
 
126
125
  context "if an active call with that ID does not exist" do
127
126
  it "should log an error explaining that the call does not exist" do
128
- flexmock(Console.logger).should_receive(:error).once.with(/does not exist/)
129
- flexmock(Console.instance).should_receive(:interact_with_call).never
127
+ Console.logger.should_receive(:error).once.with(/does not exist/)
128
+ Console.instance.should_receive(:interact_with_call).never
130
129
  Console.take call_id
131
130
  end
132
131
  end
@@ -137,19 +136,19 @@ module Adhearsion
137
136
  let(:call) { Call.new }
138
137
 
139
138
  it "should pause the call's controllers, and unpause even if the interactive controller raises" do
140
- flexmock(call).should_receive(:pause_controllers).once.ordered
141
- flexmock(CallController).should_receive(:exec).once.ordered.and_raise StandardError
142
- flexmock(call).should_receive(:resume_controllers).once.ordered
139
+ call.should_receive(:pause_controllers).once.ordered
140
+ CallController.should_receive(:exec).once.ordered.and_raise StandardError
141
+ call.should_receive(:resume_controllers).once.ordered
143
142
  lambda { Console.interact_with_call call }.should raise_error StandardError
144
143
  end
145
144
 
146
145
  it "should execute an interactive call controller on the call" do
147
- flexmock(CallController).should_receive(:exec).once.with(on do |c|
146
+ CallController.should_receive(:exec).once do |c|
148
147
  c.should be_a Console::InteractiveController
149
148
  c.call.should be call
150
- end)
149
+ end
151
150
  Console.interact_with_call call
152
151
  end
153
152
  end
154
153
  end
155
- end
154
+ end
@@ -21,7 +21,7 @@ module Adhearsion
21
21
  o = nil
22
22
  latch = CountDownLatch.new 1
23
23
 
24
- flexmock(Events.instance).should_receive(:handle_message).and_return do |message|
24
+ Events.instance.should_receive(:handle_message).and_return do |message|
25
25
  t = message.type
26
26
  o = message.object
27
27
  latch.countdown!
@@ -38,7 +38,7 @@ module Adhearsion
38
38
  t = nil
39
39
  o = nil
40
40
 
41
- flexmock(Events.instance).should_receive(:handle_message).and_return do |message|
41
+ Events.instance.should_receive(:handle_message).and_return do |message|
42
42
  sleep 0.25
43
43
  t = message.type
44
44
  o = message.object
@@ -65,7 +65,7 @@ module Adhearsion
65
65
  end
66
66
 
67
67
  it "should handle exceptions in event processing by raising the exception as an event" do
68
- flexmock(Events.instance).should_receive(:trigger).with(:exception, ExceptionClass).once
68
+ Events.instance.should_receive(:trigger).with(:exception, kind_of(ExceptionClass)).once
69
69
 
70
70
  Events.register_handler :event, EventClass do |event|
71
71
  raise ExceptionClass
@@ -12,9 +12,8 @@ describe Adhearsion::Initializer do
12
12
  describe "#start" do
13
13
  before do
14
14
  ::Logging.reset
15
- flexmock(Adhearsion::Logging).should_receive(:start).once.and_return('')
16
- flexmock(::Logging::Appenders::File).should_receive(:assert_valid_logfile).and_return(true)
17
- flexmock(::Logging::Appenders).should_receive(:file).and_return(nil)
15
+ Adhearsion::Logging.should_receive(:start).once.and_return('')
16
+ ::Logging::Appenders.stub(:file => nil)
18
17
  Adhearsion.config = nil
19
18
  end
20
19
 
@@ -35,7 +34,7 @@ describe Adhearsion::Initializer do
35
34
  end
36
35
 
37
36
  it "should start the stats aggregator" do
38
- flexmock(Adhearsion).should_receive(:statistics).at_least.once
37
+ Adhearsion.should_receive(:statistics).at_least(:once)
39
38
  stub_behavior_for_initializer_with_no_path_changing_behavior do
40
39
  Adhearsion::Initializer.start
41
40
  end
@@ -43,7 +42,7 @@ describe Adhearsion::Initializer do
43
42
 
44
43
  it "should create a pid file in the app's path when given 'true' as the pid_file hash key argument" do
45
44
  stub_behavior_for_initializer_with_no_path_changing_behavior do
46
- flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
45
+ File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
47
46
  ahn = Adhearsion::Initializer.start :pid_file => true
48
47
  ahn.pid_file[0, path.length].should be == path
49
48
  end
@@ -58,8 +57,8 @@ describe Adhearsion::Initializer do
58
57
 
59
58
  it "should create a pid file in the app's path by default when daemonizing" do
60
59
  stub_behavior_for_initializer_with_no_path_changing_behavior do
61
- flexmock(Adhearsion::CustomDaemonizer).should_receive(:daemonize).and_yield
62
- flexmock(File).should_receive(:open).once.with(File.join(path, 'adhearsion.pid'), 'w', Proc)
60
+ Adhearsion::CustomDaemonizer.should_receive(:daemonize).and_yield '123'
61
+ File.should_receive(:open).once.with(File.join(path, 'adhearsion.pid'), 'w')
63
62
  ahn = Adhearsion::Initializer.start :mode => :daemon
64
63
  ahn.pid_file[0, path.size].should be == path
65
64
  end
@@ -67,7 +66,7 @@ describe Adhearsion::Initializer do
67
66
 
68
67
  it "should NOT create a pid file in the app's path when daemonizing and :pid_file is given as false" do
69
68
  stub_behavior_for_initializer_with_no_path_changing_behavior do
70
- flexmock(Adhearsion::CustomDaemonizer).should_receive(:daemonize).and_yield
69
+ Adhearsion::CustomDaemonizer.should_receive(:daemonize).and_yield '123'
71
70
  ahn = Adhearsion::Initializer.start :mode => :daemon, :pid_file => false
72
71
  ahn.pid_file.should be nil
73
72
  end
@@ -85,55 +84,55 @@ describe Adhearsion::Initializer do
85
84
 
86
85
  it "should resolve the log file path to daemonize" do
87
86
  stub_behavior_for_initializer_with_no_path_changing_behavior do
88
- flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
89
- ahn = Adhearsion::Initializer.start :pid_file => true
90
- ahn.resolve_log_file_path.should be == path + Adhearsion.config.platform.logging.outputters[0]
87
+ File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
88
+ ahn = Adhearsion::Initializer.start :pid_file => true
89
+ ahn.resolve_log_file_path.should be == path + Adhearsion.config.platform.logging.outputters[0]
91
90
  end
92
91
  end
93
92
 
94
93
  it "should resolve the log file path to daemonize when outputters is an Array" do
95
94
  Adhearsion.config.platform.logging.outputters = ["log/my_application.log", "log/adhearsion.log"]
96
95
  stub_behavior_for_initializer_with_no_path_changing_behavior do
97
- flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
98
- ahn = Adhearsion::Initializer.start :pid_file => true
99
- ahn.resolve_log_file_path.should be == path + Adhearsion.config.platform.logging.outputters[0]
96
+ File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
97
+ ahn = Adhearsion::Initializer.start :pid_file => true
98
+ ahn.resolve_log_file_path.should be == path + Adhearsion.config.platform.logging.outputters[0]
100
99
  end
101
100
  end
102
101
 
103
102
  it "should return a valid appenders array" do
104
103
  stub_behavior_for_initializer_with_no_path_changing_behavior do
105
- flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
106
- ahn = Adhearsion::Initializer.start :pid_file => true
107
- appenders = ahn.init_get_logging_appenders
108
- appenders.should have(2).items
109
- appenders[1].should be_instance_of Logging::Appenders::Stdout
104
+ File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
105
+ ahn = Adhearsion::Initializer.start :pid_file => true
106
+ appenders = ahn.init_get_logging_appenders
107
+ appenders.should have(2).items
108
+ appenders[1].should be_instance_of Logging::Appenders::Stdout
110
109
  end
111
110
  end
112
111
 
113
112
  it "should initialize properly the log paths" do
114
113
  ahn = stub_behavior_for_initializer_with_no_path_changing_behavior do
115
- flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
114
+ File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
116
115
  Adhearsion::Initializer.start :pid_file => true
117
116
  end
118
- flexmock(Dir).should_receive(:mkdir).with("log/")
117
+ Dir.should_receive(:mkdir).with("log/")
119
118
  ahn.initialize_log_paths
120
119
  end
121
120
 
122
121
  it "should initialize properly the log paths when outputters is an array" do
123
122
  Adhearsion.config.platform.logging.outputters = ["log/my_application.log", "log/test/adhearsion.log"]
124
123
  ahn = stub_behavior_for_initializer_with_no_path_changing_behavior do
125
- flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
124
+ File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
126
125
  Adhearsion::Initializer.start :pid_file => true
127
126
  end
128
- flexmock(Dir).should_receive(:mkdir).with("log/").twice
129
- flexmock(Dir).should_receive(:mkdir).with("log/test/").once
127
+ Dir.should_receive(:mkdir).with("log/").twice
128
+ Dir.should_receive(:mkdir).with("log/test/").once
130
129
  ahn.initialize_log_paths
131
130
  end
132
131
 
133
132
  it "should set the adhearsion proc name" do
134
133
  stub_behavior_for_initializer_with_no_path_changing_behavior do
135
- flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
136
- flexmock(Adhearsion::LinuxProcName).should_receive(:set_proc_name).with(Adhearsion.config.platform.process_name)
134
+ File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
135
+ Adhearsion::LinuxProcName.should_receive(:set_proc_name).with(Adhearsion.config.platform.process_name)
137
136
  Adhearsion::Initializer.start :pid_file => true
138
137
  end
139
138
  end
@@ -149,8 +148,7 @@ describe Adhearsion::Initializer do
149
148
  describe "Initializing logger" do
150
149
  before do
151
150
  ::Logging.reset
152
- flexmock(::Logging::Appenders::File).should_receive(:assert_valid_logfile).and_return(true)
153
- flexmock(::Logging::Appenders).should_receive(:file).and_return(nil)
151
+ ::Logging::Appenders.should_receive(:file).and_return(nil)
154
152
  Adhearsion.config = nil
155
153
  end
156
154
 
@@ -163,8 +161,8 @@ describe Adhearsion::Initializer do
163
161
 
164
162
  it "should start logging with valid parameters" do
165
163
  stub_behavior_for_initializer_with_no_path_changing_behavior do
166
- flexmock(File).should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w', Proc).at_least.once
167
- flexmock(Adhearsion::Logging).should_receive(:start).once.with(Array, :info, nil).and_return('')
164
+ File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
165
+ Adhearsion::Logging.should_receive(:start).once.with(kind_of(Array), :info, nil).and_return('')
168
166
  Adhearsion::Initializer.start :pid_file => true
169
167
  end
170
168
  end
@@ -176,7 +174,7 @@ describe Adhearsion::Initializer do
176
174
  end
177
175
 
178
176
  it "should load the contents of lib directory" do
179
- flexmock(Dir).should_receive(:chdir).with(File.join(path, "lib"), Proc).and_return []
177
+ Dir.should_receive(:chdir).with(File.join(path, "lib")).and_return []
180
178
  Adhearsion::Initializer.new.load_lib_folder
181
179
  end
182
180
 
@@ -192,7 +190,8 @@ describe Adhearsion::Initializer do
192
190
 
193
191
  it "should load the contents of the preconfigured directory" do
194
192
  Adhearsion.config.platform.lib = "foo"
195
- flexmock(Dir).should_receive(:chdir).with("/any/ole/path/foo", Proc).and_return []
193
+ File.stub directory?: true
194
+ Dir.should_receive(:chdir).with(File.join(path, "foo")).and_return []
196
195
  Adhearsion::Initializer.new.load_lib_folder
197
196
  end
198
197
  end
@@ -203,9 +202,8 @@ describe "Updating RAILS_ENV variable" do
203
202
 
204
203
  before do
205
204
  ::Logging.reset
206
- flexmock(Adhearsion::Logging).should_receive(:start).once.and_return('')
207
- flexmock(::Logging::Appenders::File).should_receive(:assert_valid_logfile).and_return(true)
208
- flexmock(::Logging::Appenders).should_receive(:file).and_return(nil)
205
+ Adhearsion::Logging.should_receive(:start).once.and_return('')
206
+ ::Logging::Appenders.should_receive(:file).and_return(nil)
209
207
  Adhearsion.config = nil
210
208
  end
211
209
 
@@ -34,14 +34,14 @@ describe Adhearsion::Logging do
34
34
  it "should log to the Object logger when given arguments" do
35
35
  message = "o hai. ur home erly."
36
36
  foo = Foo.new
37
- flexmock(::Logging.logger[Foo]).should_receive(:info).once.with(message)
37
+ ::Logging.logger[Foo].should_receive(:info).once.with(message)
38
38
  foo.logger.info message
39
39
  end
40
40
 
41
41
  it "should log to the Object logger when given arguments (II)" do
42
42
  message = "o hai. ur home erly."
43
43
  bar = Foo::Bar.new
44
- flexmock(::Logging.logger[Foo::Bar]).should_receive(:info).once.with(message)
44
+ ::Logging.logger[Foo::Bar].should_receive(:info).once.with(message)
45
45
  bar.logger.info message
46
46
  end
47
47
 
@@ -86,7 +86,7 @@ describe Adhearsion::Logging do
86
86
  end
87
87
 
88
88
  it 'should reopen logfiles' do
89
- flexmock(::Logging).should_receive(:reopen).once
89
+ ::Logging.should_receive(:reopen).once
90
90
  Adhearsion::Logging.reopen_logs
91
91
  end
92
92
 
@@ -9,7 +9,7 @@ module Adhearsion
9
9
  its(:id) { should be_nil }
10
10
  its(:variables) { should be == {} }
11
11
 
12
- let(:mock_client) { flexmock 'Punchblock Client' }
12
+ let(:mock_client) { mock 'Punchblock Client' }
13
13
 
14
14
  before do
15
15
  PunchblockPlugin::Initializer.client = mock_client
@@ -24,35 +24,35 @@ module Adhearsion
24
24
 
25
25
  before do
26
26
  mock_call
27
- flexmock(OutboundCall).should_receive(:new).and_return mock_call
27
+ OutboundCall.should_receive(:new).and_return mock_call
28
28
  end
29
29
 
30
30
  it "should dial the call to the correct endpoint and return it" do
31
- flexmock(mock_call.wrapped_object).should_receive(:dial).with(to, :from => 'foo').once
31
+ mock_call.wrapped_object.should_receive(:dial).with(to, :from => 'foo').once
32
32
  OutboundCall.originate(to, :from => 'foo').should be mock_call
33
33
  end
34
34
 
35
35
  it "should run through the router when the call is answered" do
36
- flexmock(mock_call.wrapped_object).should_receive(:dial).once
36
+ mock_call.wrapped_object.should_receive(:dial).once
37
37
 
38
- flexmock(Adhearsion.router).should_receive(:handle).once.with(mock_call)
38
+ Adhearsion.router.should_receive(:handle).once.with(mock_call)
39
39
 
40
40
  OutboundCall.originate(to) << Punchblock::Event::Answered.new
41
41
  end
42
42
 
43
43
  context "when a controller class is specified for the call" do
44
- let(:controller) { CallController }
44
+ let(:controller) { CallController }
45
45
 
46
46
  it "should execute the controller on the call when it is answered" do
47
- flexmock(mock_call).should_receive(:dial).once.with(to, {})
48
- flexmock(mock_call).should_receive(:execute_controller).once.with controller, Proc
47
+ mock_call.should_receive(:dial).once.with(to, {})
48
+ mock_call.should_receive(:execute_controller).once.with kind_of(controller), kind_of(Proc)
49
49
  call = OutboundCall.originate to, :controller => controller
50
50
  call << Punchblock::Event::Answered.new
51
51
  end
52
52
 
53
53
  it "should hangup the call after all controllers have executed" do
54
- flexmock(mock_call).should_receive(:dial).once
55
- flexmock(mock_call).should_receive(:hangup).once
54
+ mock_call.should_receive(:dial).once
55
+ mock_call.should_receive(:hangup).once
56
56
 
57
57
  call = OutboundCall.originate to, :controller => controller
58
58
  call << Punchblock::Event::Answered.new
@@ -61,8 +61,10 @@ module Adhearsion
61
61
 
62
62
  context "with controller metadata specified" do
63
63
  it "should set the metadata on the controller" do
64
- flexmock(mock_call).should_receive(:dial).once.with(to, {})
65
- flexmock(mock_call).should_receive(:execute_controller).once.with(FlexMock.on { |c| c.is_a?(controller) && c.metadata == {:foo => 'bar'}}, Proc)
64
+ mock_call.should_receive(:dial).once.with(to, {})
65
+ mock_call.should_receive(:execute_controller).once do |c|
66
+ c.is_a?(controller) && c.metadata == {:foo => 'bar'}
67
+ end
66
68
  call = OutboundCall.originate to, :controller => controller, :controller_metadata => {:foo => 'bar'}
67
69
  call << Punchblock::Event::Answered.new
68
70
  end
@@ -71,8 +73,8 @@ module Adhearsion
71
73
 
72
74
  context "when given a block" do
73
75
  it "should execute the block as a controller on the call when it is answered" do
74
- flexmock(mock_call).should_receive(:dial).once.with(to, {})
75
- flexmock(mock_call).should_receive(:execute_controller).once.with(CallController, Proc).and_return do |controller|
76
+ mock_call.should_receive(:dial).once.with(to, {})
77
+ mock_call.should_receive(:execute_controller).once.with(kind_of(CallController), kind_of(Proc)).and_return do |controller|
76
78
  controller.block.call.should be == :foobar
77
79
  end
78
80
 
@@ -85,7 +87,7 @@ module Adhearsion
85
87
  end
86
88
 
87
89
  describe "event handlers" do
88
- let(:response) { flexmock 'Response' }
90
+ let(:response) { mock 'Response' }
89
91
 
90
92
  describe "for answered events" do
91
93
  let(:event) { Punchblock::Event::Answered.new }
@@ -100,7 +102,7 @@ module Adhearsion
100
102
 
101
103
  describe "#dial" do
102
104
  def expect_message_waiting_for_response(message)
103
- flexmock(subject.wrapped_object).should_receive(:write_and_await_response).once.with(message, 60).and_return do
105
+ subject.wrapped_object.should_receive(:write_and_await_response).once.with(message, 60).and_return do
104
106
  message.target_call_id = call_id
105
107
  message
106
108
  end
@@ -141,13 +143,13 @@ module Adhearsion
141
143
  end
142
144
 
143
145
  it "should add the call to the active calls registry" do
144
- Adhearsion.active_calls.clear!
146
+ Adhearsion.active_calls.clear
145
147
  subject.dial to, :from => from
146
148
  Adhearsion.active_calls[call_id].should be subject
147
149
  end
148
150
 
149
151
  it "should immediately fire the :call_dialed event giving the call" do
150
- flexmock(Adhearsion::Events).should_receive(:trigger_immediately).once.with(:call_dialed, subject)
152
+ Adhearsion::Events.should_receive(:trigger_immediately).once.with(:call_dialed, subject)
151
153
  subject.dial to, :from => from
152
154
  end
153
155
 
@@ -162,7 +164,7 @@ module Adhearsion
162
164
 
163
165
  describe "basic control commands" do
164
166
  def expect_no_message_waiting_for_response
165
- flexmock(subject.wrapped_object).should_receive(:write_and_await_response).never
167
+ subject.wrapped_object.should_receive(:write_and_await_response).never
166
168
  end
167
169
 
168
170
  describe '#accept' do