adhearsion 2.5.4 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +15 -0
  4. data/README.markdown +2 -1
  5. data/Rakefile +1 -6
  6. data/adhearsion.gemspec +4 -3
  7. data/features/cli_daemon.feature +2 -4
  8. data/features/cli_restart.feature +14 -5
  9. data/features/cli_start.feature +0 -2
  10. data/features/cli_stop.feature +15 -6
  11. data/lib/adhearsion.rb +21 -23
  12. data/lib/adhearsion/call.rb +49 -5
  13. data/lib/adhearsion/call_controller.rb +29 -11
  14. data/lib/adhearsion/call_controller/dial.rb +21 -9
  15. data/lib/adhearsion/call_controller/menu_dsl.rb +12 -12
  16. data/lib/adhearsion/call_controller/menu_dsl/array_match_calculator.rb +1 -1
  17. data/lib/adhearsion/call_controller/menu_dsl/fixnum_match_calculator.rb +1 -0
  18. data/lib/adhearsion/call_controller/menu_dsl/string_match_calculator.rb +1 -1
  19. data/lib/adhearsion/call_controller/output.rb +36 -7
  20. data/lib/adhearsion/call_controller/output/abstract_player.rb +4 -0
  21. data/lib/adhearsion/call_controller/record.rb +1 -0
  22. data/lib/adhearsion/cli_commands/ahn_command.rb +7 -4
  23. data/lib/adhearsion/cli_commands/plugin_command.rb +2 -0
  24. data/lib/adhearsion/generators.rb +2 -4
  25. data/lib/adhearsion/generators/app/templates/simon_game_spec.rb +20 -20
  26. data/lib/adhearsion/initializer.rb +2 -2
  27. data/lib/adhearsion/plugin.rb +6 -6
  28. data/lib/adhearsion/punchblock_plugin.rb +3 -4
  29. data/lib/adhearsion/punchblock_plugin/initializer.rb +2 -1
  30. data/lib/adhearsion/router.rb +7 -7
  31. data/lib/adhearsion/router/route.rb +10 -4
  32. data/lib/adhearsion/rspec.rb +2 -0
  33. data/lib/adhearsion/version.rb +1 -1
  34. data/spec/adhearsion/call_controller/dial_spec.rb +589 -557
  35. data/spec/adhearsion/call_controller/input_spec.rb +91 -91
  36. data/spec/adhearsion/call_controller/menu_dsl/array_match_calculator_spec.rb +29 -29
  37. data/spec/adhearsion/call_controller/menu_dsl/calculated_match_collection_spec.rb +6 -6
  38. data/spec/adhearsion/call_controller/menu_dsl/calculated_match_spec.rb +19 -19
  39. data/spec/adhearsion/call_controller/menu_dsl/fixnum_match_calculator_spec.rb +6 -6
  40. data/spec/adhearsion/call_controller/menu_dsl/match_calculator_spec.rb +1 -1
  41. data/spec/adhearsion/call_controller/menu_dsl/menu_builder_spec.rb +21 -17
  42. data/spec/adhearsion/call_controller/menu_dsl/menu_spec.rb +96 -83
  43. data/spec/adhearsion/call_controller/menu_dsl/range_match_calculator_spec.rb +5 -5
  44. data/spec/adhearsion/call_controller/menu_dsl/string_match_calculator_spec.rb +9 -9
  45. data/spec/adhearsion/call_controller/output/async_player_spec.rb +14 -4
  46. data/spec/adhearsion/call_controller/output/formatter_spec.rb +14 -14
  47. data/spec/adhearsion/call_controller/output/player_spec.rb +15 -5
  48. data/spec/adhearsion/call_controller/output_spec.rb +126 -78
  49. data/spec/adhearsion/call_controller/record_spec.rb +38 -26
  50. data/spec/adhearsion/call_controller/utility_spec.rb +11 -11
  51. data/spec/adhearsion/call_controller_spec.rb +176 -136
  52. data/spec/adhearsion/call_spec.rb +443 -218
  53. data/spec/adhearsion/calls_spec.rb +33 -33
  54. data/spec/adhearsion/configuration_spec.rb +61 -61
  55. data/spec/adhearsion/console_spec.rb +29 -29
  56. data/spec/adhearsion/events_spec.rb +14 -14
  57. data/spec/adhearsion/generators_spec.rb +1 -1
  58. data/spec/adhearsion/initializer_spec.rb +42 -42
  59. data/spec/adhearsion/logging_spec.rb +33 -33
  60. data/spec/adhearsion/outbound_call_spec.rb +69 -55
  61. data/spec/adhearsion/plugin_spec.rb +53 -44
  62. data/spec/adhearsion/process_spec.rb +21 -21
  63. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +68 -52
  64. data/spec/adhearsion/punchblock_plugin_spec.rb +6 -6
  65. data/spec/adhearsion/router/evented_route_spec.rb +2 -2
  66. data/spec/adhearsion/router/openended_route_spec.rb +9 -9
  67. data/spec/adhearsion/router/route_spec.rb +61 -31
  68. data/spec/adhearsion/router/unaccepting_route_spec.rb +13 -13
  69. data/spec/adhearsion/router_spec.rb +47 -33
  70. data/spec/adhearsion/statistics/dump_spec.rb +6 -6
  71. data/spec/adhearsion/statistics_spec.rb +9 -9
  72. data/spec/adhearsion_spec.rb +23 -20
  73. data/spec/spec_helper.rb +3 -6
  74. data/spec/support/call_controller_test_helpers.rb +7 -7
  75. data/spec/support/initializer_stubs.rb +1 -1
  76. data/spec/support/punchblock_mocks.rb +1 -1
  77. metadata +22 -10
  78. data/features/support/utils.rb +0 -9
@@ -11,19 +11,19 @@ module Adhearsion
11
11
  digits_that_begin_with_eleven = [110..119, 1100..1111].map { |x| Array(x) }.flatten
12
12
  calculator = RangeMatchCalculator.new 11..1111, :match_payload_doesnt_matter
13
13
  match = calculator.match '11'
14
- match.exact_matches.should be == ['11']
15
- match.potential_matches.should be == digits_that_begin_with_eleven
14
+ expect(match.exact_matches).to eq(['11'])
15
+ expect(match.potential_matches).to eq(digits_that_begin_with_eleven)
16
16
  end
17
17
 
18
18
  it "return values of #match should be an instance of CalculatedMatch" do
19
19
  calculator = RangeMatchCalculator.new 1..9, :match_payload_doesnt_matter
20
- calculator.match('0').should be_an_instance_of CalculatedMatch
21
- calculator.match('1000').should be_an_instance_of CalculatedMatch
20
+ expect(calculator.match('0')).to be_an_instance_of CalculatedMatch
21
+ expect(calculator.match('1000')).to be_an_instance_of CalculatedMatch
22
22
  end
23
23
 
24
24
  it "returns a failed match if the query is not numeric or coercible to numeric" do
25
25
  calculator = RangeMatchCalculator.new 1..9, :match_payload_doesnt_matter
26
- calculator.match("ABC").should be_an_instance_of CalculatedMatch
26
+ expect(calculator.match("ABC")).to be_an_instance_of CalculatedMatch
27
27
  end
28
28
  end
29
29
 
@@ -14,14 +14,14 @@ module Adhearsion
14
14
  calculator = StringMatchCalculator.new str, match_payload
15
15
 
16
16
  match_case = calculator.match str[0,2]
17
- match_case.should_not be_exact_match
18
- match_case.should be_potential_match
19
- match_case.potential_matches.should be == [str]
17
+ expect(match_case).not_to be_exact_match
18
+ expect(match_case).to be_potential_match
19
+ expect(match_case.potential_matches).to eq([str])
20
20
 
21
21
  match_case = calculator.match str
22
- match_case.should be_exact_match
23
- match_case.should_not be_potential_match
24
- match_case.exact_matches.should be == [str]
22
+ expect(match_case).to be_exact_match
23
+ expect(match_case).not_to be_potential_match
24
+ expect(match_case.exact_matches).to eq([str])
25
25
  end
26
26
  end
27
27
 
@@ -29,9 +29,9 @@ module Adhearsion
29
29
  %w[* #].each do |special_digit|
30
30
  calculator = StringMatchCalculator.new(special_digit, match_payload)
31
31
  match_case = calculator.match special_digit
32
- match_case.exact_matches.first.should be == special_digit
33
- match_case.should be_exact_match
34
- match_case.should_not be_potential_match
32
+ expect(match_case.exact_matches.first).to eq(special_digit)
33
+ expect(match_case).to be_exact_match
34
+ expect(match_case).not_to be_potential_match
35
35
  end
36
36
  end
37
37
  end
@@ -31,21 +31,21 @@ module Adhearsion
31
31
  it "returns the component" do
32
32
  component = Punchblock::Component::Output.new :ssml => content
33
33
  expect_message_waiting_for_response component
34
- subject.output(content).should be_a Punchblock::Component::Output
34
+ expect(subject.output(content)).to be_a Punchblock::Component::Output
35
35
  end
36
36
 
37
37
  it "raises a PlaybackError if the component fails to start" do
38
38
  expect_message_waiting_for_response Punchblock::Component::Output.new(:ssml => content), Punchblock::ProtocolError
39
- lambda { subject.output content }.should raise_error(PlaybackError)
39
+ expect { subject.output content }.to raise_error(PlaybackError)
40
40
  end
41
41
 
42
42
  it "logs the complete event if it is an error" do
43
43
  response = Punchblock::Event::Complete.new
44
44
  response.reason = Punchblock::Event::Complete::Error.new
45
45
  component = Punchblock::Component::Output.new(:ssml => content)
46
- subject.stub :new_output => component
46
+ allow(subject).to receive_messages :new_output => component
47
47
  expect_message_waiting_for_response component
48
- controller.logger.should_receive(:error).once
48
+ expect(controller.logger).to receive(:error).once
49
49
  subject.output content
50
50
  component.request!
51
51
  component.execute!
@@ -62,6 +62,16 @@ module Adhearsion
62
62
  subject.play_ssml ssml
63
63
  end
64
64
  end
65
+
66
+ describe "#play_url" do
67
+ let(:url) { "http://example.com/ex.ssml" }
68
+
69
+ it 'executes an Output with the URL' do
70
+ component = Punchblock::Component::Output.new({render_document: {value: url, content_type: "application/ssml+xml"}})
71
+ expect_message_waiting_for_response component
72
+ subject.play_url url
73
+ end
74
+ end
65
75
  end
66
76
  end
67
77
  end
@@ -15,11 +15,11 @@ module Adhearsion
15
15
  end
16
16
 
17
17
  it 'returns SSML for a text argument' do
18
- subject.ssml_for(prompt).should be == ssml
18
+ expect(subject.ssml_for(prompt)).to eq(ssml)
19
19
  end
20
20
 
21
21
  it 'returns the same SSML passed in if it is SSML' do
22
- subject.ssml_for(ssml).should be == ssml
22
+ expect(subject.ssml_for(ssml)).to eq(ssml)
23
23
  end
24
24
  end
25
25
 
@@ -39,60 +39,60 @@ module Adhearsion
39
39
  end
40
40
 
41
41
  it "should create a composite SSML document" do
42
- subject.ssml_for_collection(collection).should be == ssml
42
+ expect(subject.ssml_for_collection(collection)).to eq(ssml)
43
43
  end
44
44
  end
45
45
 
46
46
  describe "#detect_type" do
47
47
  it "detects an HTTP path" do
48
48
  http_path = "http://adhearsion.com/sounds/hello.mp3"
49
- subject.detect_type(http_path).should be :audio
49
+ expect(subject.detect_type(http_path)).to be :audio
50
50
  end
51
51
 
52
52
  it "detects a file path" do
53
53
  file_path = "file:///usr/shared/sounds/hello.mp3"
54
- subject.detect_type(file_path).should be :audio
54
+ expect(subject.detect_type(file_path)).to be :audio
55
55
 
56
56
  absolute_path = "/usr/shared/sounds/hello.mp3"
57
- subject.detect_type(absolute_path).should be :audio
57
+ expect(subject.detect_type(absolute_path)).to be :audio
58
58
 
59
59
  relative_path = "foo/bar"
60
- subject.detect_type(relative_path).should_not be :audio
60
+ expect(subject.detect_type(relative_path)).not_to be :audio
61
61
  end
62
62
 
63
63
  it "detects a Date object" do
64
64
  today = Date.today
65
- subject.detect_type(today).should be :time
65
+ expect(subject.detect_type(today)).to be :time
66
66
  end
67
67
 
68
68
  it "detects a Time object" do
69
69
  now = Time.now
70
- subject.detect_type(now).should be :time
70
+ expect(subject.detect_type(now)).to be :time
71
71
  end
72
72
 
73
73
  it "detects a DateTime object" do
74
74
  today = DateTime.now
75
- subject.detect_type(today).should be :time
75
+ expect(subject.detect_type(today)).to be :time
76
76
  end
77
77
 
78
78
  it "detects a Numeric object" do
79
79
  number = 123
80
- subject.detect_type(number).should be :numeric
80
+ expect(subject.detect_type(number)).to be :numeric
81
81
  end
82
82
 
83
83
  it "detects a String of digits" do
84
84
  number = '123'
85
- subject.detect_type(number).should be :numeric
85
+ expect(subject.detect_type(number)).to be :numeric
86
86
  end
87
87
 
88
88
  it "detects a String of characters" do
89
89
  number = '123#'
90
- subject.detect_type(number).should be :characters
90
+ expect(subject.detect_type(number)).to be :characters
91
91
  end
92
92
 
93
93
  ["Foo", "Foo bar", "The answer: foo", "The answer could be foo/bar"].each do |string|
94
94
  it "detects '#{string}' as text" do
95
- subject.detect_type(string).should be :text
95
+ expect(subject.detect_type(string)).to be :text
96
96
  end
97
97
  end
98
98
  end
@@ -30,7 +30,7 @@ module Adhearsion
30
30
  it "yields the component to the block before waiting for it to finish" do
31
31
  component = Punchblock::Component::Output.new :ssml => content
32
32
 
33
- controller.should_receive(:execute_component_and_await_completion).once.with(component).and_yield(:foo)
33
+ expect(controller).to receive(:execute_component_and_await_completion).once.with(component).and_yield(:foo)
34
34
 
35
35
  @foo = nil
36
36
 
@@ -38,22 +38,22 @@ module Adhearsion
38
38
  @foo = comp
39
39
  end
40
40
 
41
- @foo.should == :foo
41
+ expect(@foo).to eq(:foo)
42
42
  end
43
43
 
44
44
  it "raises a PlaybackError if the component fails to start" do
45
45
  expect_component_execution Punchblock::Component::Output.new(:ssml => content), Punchblock::ProtocolError
46
- lambda { subject.output content }.should raise_error(PlaybackError)
46
+ expect { subject.output content }.to raise_error(PlaybackError)
47
47
  end
48
48
 
49
49
  it "raises a Playback Error if the component ends due to an error" do
50
50
  expect_component_execution Punchblock::Component::Output.new(:ssml => content), Adhearsion::Error
51
- lambda { subject.output content }.should raise_error(PlaybackError)
51
+ expect { subject.output content }.to raise_error(PlaybackError)
52
52
  end
53
53
 
54
54
  it "raises a Call::Hangup exception if the component ends due to an error" do
55
55
  expect_component_execution Punchblock::Component::Output.new(:ssml => content), Call::Hangup
56
- lambda { subject.output content }.should raise_error(Call::Hangup)
56
+ expect { subject.output content }.to raise_error(Call::Hangup)
57
57
  end
58
58
  end
59
59
 
@@ -65,6 +65,16 @@ module Adhearsion
65
65
  subject.play_ssml ssml
66
66
  end
67
67
  end
68
+
69
+ describe "#play_url" do
70
+ let(:url) { "http://example.com/ex.ssml" }
71
+
72
+ it 'executes an Output with the URL' do
73
+ component = Punchblock::Component::Output.new({render_document: {value: url, content_type: "application/ssml+xml"}})
74
+ expect_component_execution component
75
+ subject.play_url url
76
+ end
77
+ end
68
78
  end
69
79
  end
70
80
  end
@@ -16,19 +16,29 @@ module Adhearsion
16
16
  expect_message_waiting_for_response Punchblock::Component::Output.new(options.merge(:ssml => ssml))
17
17
  end
18
18
 
19
+ def expect_url_output(url, options = {})
20
+ component = Punchblock::Component::Output.new(options.merge(render_document: {value: url, content_type: "application/ssml+xml"}))
21
+ expect_component_execution component
22
+ end
23
+
24
+ def expect_async_url_output(url, options = {})
25
+ component = Punchblock::Component::Output.new(options.merge(render_document: {value: url, content_type: "application/ssml+xml"}))
26
+ expect_message_waiting_for_response component
27
+ end
28
+
19
29
  describe "#player" do
20
30
  it "should return a Player component targetted at the current controller" do
21
31
  player = controller.player
22
- player.should be_a Output::Player
23
- player.controller.should be controller
32
+ expect(player).to be_a Output::Player
33
+ expect(player.controller).to be controller
24
34
  end
25
35
  end
26
36
 
27
37
  describe "#async_player" do
28
38
  it "should return an AsyncPlayer component targetted at the current controller" do
29
39
  player = controller.async_player
30
- player.should be_a Output::AsyncPlayer
31
- player.controller.should be controller
40
+ expect(player).to be_a Output::AsyncPlayer
41
+ expect(player.controller).to be controller
32
42
  end
33
43
  end
34
44
 
@@ -42,7 +52,7 @@ module Adhearsion
42
52
 
43
53
  it 'plays the correct ssml' do
44
54
  expect_ssml_output ssml
45
- subject.play_audio(audio_file).should be true
55
+ expect(subject.play_audio(audio_file)).to be true
46
56
  end
47
57
 
48
58
  context "with a fallback" do
@@ -58,7 +68,7 @@ module Adhearsion
58
68
 
59
69
  it 'places the fallback in the SSML doc' do
60
70
  expect_ssml_output ssml
61
- subject.play_audio(audio_file, :fallback => fallback).should be true
71
+ expect(subject.play_audio(audio_file, :fallback => fallback)).to be true
62
72
  end
63
73
  end
64
74
 
@@ -66,7 +76,7 @@ module Adhearsion
66
76
  let(:media_engine) { :native }
67
77
  it "should use the specified media engine in the component" do
68
78
  expect_ssml_output ssml, renderer: media_engine
69
- subject.play_audio(audio_file, renderer: media_engine).should be true
79
+ expect(subject.play_audio(audio_file, renderer: media_engine)).to be true
70
80
  end
71
81
  end
72
82
  end
@@ -81,7 +91,7 @@ module Adhearsion
81
91
 
82
92
  it 'plays the correct ssml' do
83
93
  expect_async_ssml_output ssml
84
- subject.play_audio!(audio_file).should be_a Punchblock::Component::Output
94
+ expect(subject.play_audio!(audio_file)).to be_a Punchblock::Component::Output
85
95
  end
86
96
 
87
97
  context "with a fallback" do
@@ -97,7 +107,7 @@ module Adhearsion
97
107
 
98
108
  it 'places the fallback in the SSML doc' do
99
109
  expect_async_ssml_output ssml
100
- subject.play_audio!(audio_file, :fallback => fallback).should be_a Punchblock::Component::Output
110
+ expect(subject.play_audio!(audio_file, :fallback => fallback)).to be_a Punchblock::Component::Output
101
111
  end
102
112
  end
103
113
 
@@ -105,7 +115,7 @@ module Adhearsion
105
115
  let(:media_engine) { :native }
106
116
  it "should use the specified media engine in the SSML" do
107
117
  expect_async_ssml_output ssml, renderer: media_engine
108
- subject.play_audio!(audio_file, renderer: media_engine).should be_a Punchblock::Component::Output
118
+ expect(subject.play_audio!(audio_file, renderer: media_engine)).to be_a Punchblock::Component::Output
109
119
  end
110
120
  end
111
121
  end
@@ -122,7 +132,7 @@ module Adhearsion
122
132
 
123
133
  it 'plays the correct ssml' do
124
134
  expect_ssml_output ssml
125
- subject.play_numeric(input).should be true
135
+ expect(subject.play_numeric(input)).to be true
126
136
  end
127
137
  end
128
138
 
@@ -131,7 +141,7 @@ module Adhearsion
131
141
 
132
142
  it 'plays the correct ssml' do
133
143
  expect_ssml_output ssml
134
- subject.play_numeric(input).should be true
144
+ expect(subject.play_numeric(input)).to be true
135
145
  end
136
146
  end
137
147
 
@@ -139,7 +149,7 @@ module Adhearsion
139
149
  let(:input) { 'foo' }
140
150
 
141
151
  it 'raises ArgumentError' do
142
- lambda { subject.play_numeric input }.should raise_error(ArgumentError)
152
+ expect { subject.play_numeric input }.to raise_error(ArgumentError)
143
153
  end
144
154
  end
145
155
 
@@ -149,7 +159,7 @@ module Adhearsion
149
159
 
150
160
  it "should use the specified renderer in the SSML" do
151
161
  expect_ssml_output ssml, renderer: renderer
152
- subject.play_numeric(input, renderer: renderer).should be true
162
+ expect(subject.play_numeric(input, renderer: renderer)).to be true
153
163
  end
154
164
  end
155
165
  end
@@ -166,7 +176,7 @@ module Adhearsion
166
176
 
167
177
  it 'plays the correct ssml' do
168
178
  expect_async_ssml_output ssml
169
- subject.play_numeric!(input).should be_a Punchblock::Component::Output
179
+ expect(subject.play_numeric!(input)).to be_a Punchblock::Component::Output
170
180
  end
171
181
  end
172
182
 
@@ -175,7 +185,7 @@ module Adhearsion
175
185
 
176
186
  it 'plays the correct ssml' do
177
187
  expect_async_ssml_output ssml
178
- subject.play_numeric!(input).should be_a Punchblock::Component::Output
188
+ expect(subject.play_numeric!(input)).to be_a Punchblock::Component::Output
179
189
  end
180
190
  end
181
191
 
@@ -183,7 +193,7 @@ module Adhearsion
183
193
  let(:input) { 'foo' }
184
194
 
185
195
  it 'raises ArgumentError' do
186
- lambda { subject.play_numeric! input }.should raise_error(ArgumentError)
196
+ expect { subject.play_numeric! input }.to raise_error(ArgumentError)
187
197
  end
188
198
  end
189
199
 
@@ -193,7 +203,45 @@ module Adhearsion
193
203
 
194
204
  it "should use the specified renderer in the SSML" do
195
205
  expect_async_ssml_output ssml, renderer: renderer
196
- subject.play_numeric!(input, renderer: renderer).should be_a Punchblock::Component::Output
206
+ expect(subject.play_numeric!(input, renderer: renderer)).to be_a Punchblock::Component::Output
207
+ end
208
+ end
209
+ end
210
+
211
+ describe "#play_document" do
212
+ describe "with a URL" do
213
+ let(:input) { 'http://example.com/ex.ssml' }
214
+
215
+ it 'plays the url' do
216
+ expect_url_output input
217
+ expect(subject.play_document(input)).to be true
218
+ end
219
+ end
220
+
221
+ describe "with something that's not a URL" do
222
+ let(:input) { 'ceci n\'est pas une url' }
223
+
224
+ it 'raises ArgumentError' do
225
+ expect { subject.play_document input }.to raise_error(ArgumentError)
226
+ end
227
+ end
228
+ end
229
+
230
+ describe "#play_document!" do
231
+ describe "with a URL" do
232
+ let(:input) { 'http://example.com/ex.ssml' }
233
+
234
+ it 'plays the url' do
235
+ expect_async_url_output input
236
+ expect(subject.play_document!(input)).to be_a Punchblock::Component::Output
237
+ end
238
+ end
239
+
240
+ describe "with something that's not a URL" do
241
+ let(:input) { 'ceci n\'est pas une url' }
242
+
243
+ it 'raises ArgumentError' do
244
+ expect { subject.play_document! input }.to raise_error(ArgumentError)
197
245
  end
198
246
  end
199
247
  end
@@ -213,7 +261,7 @@ module Adhearsion
213
261
 
214
262
  it 'plays the correct SSML' do
215
263
  expect_ssml_output ssml
216
- subject.play_time(input).should be true
264
+ expect(subject.play_time(input)).to be true
217
265
  end
218
266
  end
219
267
 
@@ -223,7 +271,7 @@ module Adhearsion
223
271
 
224
272
  it 'plays the correct SSML' do
225
273
  expect_ssml_output ssml
226
- subject.play_time(input).should be true
274
+ expect(subject.play_time(input)).to be true
227
275
  end
228
276
  end
229
277
 
@@ -234,7 +282,7 @@ module Adhearsion
234
282
 
235
283
  it 'plays the correct SSML' do
236
284
  expect_ssml_output ssml
237
- subject.play_time(input, :format => format).should be true
285
+ expect(subject.play_time(input, :format => format)).to be true
238
286
  end
239
287
  end
240
288
 
@@ -246,7 +294,7 @@ module Adhearsion
246
294
 
247
295
  it 'plays the correct SSML' do
248
296
  expect_ssml_output ssml
249
- subject.play_time(base_input, :strftime => strftime).should be true
297
+ expect(subject.play_time(base_input, :strftime => strftime)).to be true
250
298
  end
251
299
  end
252
300
 
@@ -259,7 +307,7 @@ module Adhearsion
259
307
 
260
308
  it 'plays the correct SSML' do
261
309
  expect_ssml_output ssml
262
- subject.play_time(base_input, :format => format, :strftime => strftime).should be true
310
+ expect(subject.play_time(base_input, :format => format, :strftime => strftime)).to be true
263
311
  end
264
312
  end
265
313
 
@@ -271,7 +319,7 @@ module Adhearsion
271
319
 
272
320
  it "should use the specified renderer in the SSML" do
273
321
  expect_ssml_output ssml, renderer: renderer
274
- subject.play_time(input, format: format, renderer: renderer).should be true
322
+ expect(subject.play_time(input, format: format, renderer: renderer)).to be true
275
323
  end
276
324
  end
277
325
 
@@ -279,7 +327,7 @@ module Adhearsion
279
327
  let(:input) { "foo" }
280
328
 
281
329
  it 'raises ArgumentError' do
282
- lambda { subject.play_time input }.should raise_error(ArgumentError)
330
+ expect { subject.play_time input }.to raise_error(ArgumentError)
283
331
  end
284
332
  end
285
333
  end
@@ -299,7 +347,7 @@ module Adhearsion
299
347
 
300
348
  it 'plays the correct SSML' do
301
349
  expect_async_ssml_output ssml
302
- subject.play_time!(input).should be_a Punchblock::Component::Output
350
+ expect(subject.play_time!(input)).to be_a Punchblock::Component::Output
303
351
  end
304
352
  end
305
353
 
@@ -309,7 +357,7 @@ module Adhearsion
309
357
 
310
358
  it 'plays the correct SSML' do
311
359
  expect_async_ssml_output ssml
312
- subject.play_time!(input).should be_a Punchblock::Component::Output
360
+ expect(subject.play_time!(input)).to be_a Punchblock::Component::Output
313
361
  end
314
362
  end
315
363
 
@@ -320,7 +368,7 @@ module Adhearsion
320
368
 
321
369
  it 'plays the correct SSML' do
322
370
  expect_async_ssml_output ssml
323
- subject.play_time!(input, :format => format).should be_a Punchblock::Component::Output
371
+ expect(subject.play_time!(input, :format => format)).to be_a Punchblock::Component::Output
324
372
  end
325
373
  end
326
374
 
@@ -332,7 +380,7 @@ module Adhearsion
332
380
 
333
381
  it 'plays the correct SSML' do
334
382
  expect_async_ssml_output ssml
335
- subject.play_time!(base_input, :strftime => strftime).should be_a Punchblock::Component::Output
383
+ expect(subject.play_time!(base_input, :strftime => strftime)).to be_a Punchblock::Component::Output
336
384
  end
337
385
  end
338
386
 
@@ -345,7 +393,7 @@ module Adhearsion
345
393
 
346
394
  it 'plays the correct SSML' do
347
395
  expect_async_ssml_output ssml
348
- subject.play_time!(base_input, :format => format, :strftime => strftime).should be_a Punchblock::Component::Output
396
+ expect(subject.play_time!(base_input, :format => format, :strftime => strftime)).to be_a Punchblock::Component::Output
349
397
  end
350
398
  end
351
399
 
@@ -357,7 +405,7 @@ module Adhearsion
357
405
 
358
406
  it "should use the specified renderer in the SSML" do
359
407
  expect_async_ssml_output ssml, renderer: renderer
360
- subject.play_time!(input, format: format, renderer: renderer).should be_a Punchblock::Component::Output
408
+ expect(subject.play_time!(input, format: format, renderer: renderer)).to be_a Punchblock::Component::Output
361
409
  end
362
410
  end
363
411
 
@@ -365,7 +413,7 @@ module Adhearsion
365
413
  let(:input) { "foo" }
366
414
 
367
415
  it 'raises ArgumentError' do
368
- lambda { subject.play_time! input }.should raise_error(ArgumentError)
416
+ expect { subject.play_time! input }.to raise_error(ArgumentError)
369
417
  end
370
418
  end
371
419
  end
@@ -390,12 +438,12 @@ module Adhearsion
390
438
 
391
439
  it 'plays the audio file' do
392
440
  expect_ssml_output ssml
393
- subject.play(audio_file).should be true
441
+ expect(subject.play(audio_file)).to be true
394
442
  end
395
443
 
396
444
  it 'plays the audio file with the specified extra options if present' do
397
445
  expect_ssml_output ssml, extra_options
398
- subject.play(audio_file, extra_options).should be true
446
+ expect(subject.play(audio_file, extra_options)).to be true
399
447
  end
400
448
  end
401
449
 
@@ -416,13 +464,13 @@ module Adhearsion
416
464
 
417
465
  it 'plays all arguments in one document' do
418
466
  expect_ssml_output ssml
419
- subject.play(*args).should be true
467
+ expect(subject.play(*args)).to be true
420
468
  end
421
469
 
422
470
  it 'plays all arguments in one document with the extra options if present' do
423
471
  expect_ssml_output ssml, extra_options
424
472
  args << extra_options
425
- subject.play(*args).should be true
473
+ expect(subject.play(*args)).to be true
426
474
  end
427
475
  end
428
476
 
@@ -441,7 +489,7 @@ module Adhearsion
441
489
 
442
490
  it 'plays all arguments in one document' do
443
491
  expect_ssml_output ssml
444
- subject.play(args).should be true
492
+ expect(subject.play(args)).to be true
445
493
  end
446
494
 
447
495
  context "that is empty" do
@@ -463,7 +511,7 @@ module Adhearsion
463
511
 
464
512
  it 'plays the number' do
465
513
  expect_ssml_output ssml
466
- subject.play(argument).should be true
514
+ expect(subject.play(argument)).to be true
467
515
  end
468
516
  end
469
517
 
@@ -479,7 +527,7 @@ module Adhearsion
479
527
 
480
528
  it 'plays the number' do
481
529
  expect_ssml_output ssml
482
- subject.play(argument).should be true
530
+ expect(subject.play(argument)).to be true
483
531
  end
484
532
  end
485
533
 
@@ -495,7 +543,7 @@ module Adhearsion
495
543
 
496
544
  it 'plays the time' do
497
545
  expect_ssml_output ssml
498
- subject.play(time).should be true
546
+ expect(subject.play(time)).to be true
499
547
  end
500
548
  end
501
549
 
@@ -510,7 +558,7 @@ module Adhearsion
510
558
 
511
559
  it 'plays the time' do
512
560
  expect_ssml_output ssml
513
- subject.play(date).should be true
561
+ expect(subject.play(date)).to be true
514
562
  end
515
563
  end
516
564
 
@@ -529,7 +577,7 @@ module Adhearsion
529
577
 
530
578
  it 'plays the time with the specified format and strftime' do
531
579
  expect_ssml_output ssml
532
- subject.play(:value => date, :format => format, :strftime => strftime).should be true
580
+ expect(subject.play(:value => date, :format => format, :strftime => strftime)).to be true
533
581
  end
534
582
  end
535
583
 
@@ -538,7 +586,7 @@ module Adhearsion
538
586
 
539
587
  it "plays the SSML without generating" do
540
588
  expect_ssml_output ssml
541
- subject.play(ssml).should be true
589
+ expect(subject.play(ssml)).to be true
542
590
  end
543
591
  end
544
592
  end
@@ -563,7 +611,7 @@ module Adhearsion
563
611
 
564
612
  it 'plays the audio file' do
565
613
  expect_async_ssml_output ssml
566
- subject.play!(audio_file).should be_a Punchblock::Component::Output
614
+ expect(subject.play!(audio_file)).to be_a Punchblock::Component::Output
567
615
  end
568
616
 
569
617
  it 'plays the audio file with the specified extra options if present' do
@@ -587,7 +635,7 @@ module Adhearsion
587
635
 
588
636
  it 'plays all arguments in one document' do
589
637
  expect_async_ssml_output ssml
590
- subject.play!(*args).should be_a Punchblock::Component::Output
638
+ expect(subject.play!(*args)).to be_a Punchblock::Component::Output
591
639
  end
592
640
 
593
641
  it 'plays all arguments in one document with the extra options if present' do
@@ -609,7 +657,7 @@ module Adhearsion
609
657
 
610
658
  it 'plays the number' do
611
659
  expect_async_ssml_output ssml
612
- subject.play!(argument).should be_a Punchblock::Component::Output
660
+ expect(subject.play!(argument)).to be_a Punchblock::Component::Output
613
661
  end
614
662
  end
615
663
 
@@ -625,7 +673,7 @@ module Adhearsion
625
673
 
626
674
  it 'plays the number' do
627
675
  expect_async_ssml_output ssml
628
- subject.play!(argument).should be_a Punchblock::Component::Output
676
+ expect(subject.play!(argument)).to be_a Punchblock::Component::Output
629
677
  end
630
678
  end
631
679
 
@@ -641,7 +689,7 @@ module Adhearsion
641
689
 
642
690
  it 'plays the time' do
643
691
  expect_async_ssml_output ssml
644
- subject.play!(time).should be_a Punchblock::Component::Output
692
+ expect(subject.play!(time)).to be_a Punchblock::Component::Output
645
693
  end
646
694
  end
647
695
 
@@ -656,7 +704,7 @@ module Adhearsion
656
704
 
657
705
  it 'plays the time' do
658
706
  expect_async_ssml_output ssml
659
- subject.play!(date).should be_a Punchblock::Component::Output
707
+ expect(subject.play!(date)).to be_a Punchblock::Component::Output
660
708
  end
661
709
  end
662
710
 
@@ -675,7 +723,7 @@ module Adhearsion
675
723
 
676
724
  it 'plays the time with the specified format and strftime' do
677
725
  expect_async_ssml_output ssml
678
- subject.play!(:value => date, :format => format, :strftime => strftime).should be_a Punchblock::Component::Output
726
+ expect(subject.play!(:value => date, :format => format, :strftime => strftime)).to be_a Punchblock::Component::Output
679
727
  end
680
728
  end
681
729
 
@@ -684,7 +732,7 @@ module Adhearsion
684
732
 
685
733
  it "plays the SSML without generating" do
686
734
  expect_async_ssml_output ssml
687
- subject.play!(ssml).should be_a Punchblock::Component::Output
735
+ expect(subject.play!(ssml)).to be_a Punchblock::Component::Output
688
736
  end
689
737
  end
690
738
  end
@@ -696,26 +744,26 @@ module Adhearsion
696
744
  let(:extra_options) { {renderer: :native } }
697
745
 
698
746
  it "plays two outputs in succession" do
699
- subject.should_receive(:stream_file).twice
747
+ expect(subject).to receive(:stream_file).twice
700
748
  digit = subject.interruptible_play output1, output2
701
- digit.should be_nil
749
+ expect(digit).to be_nil
702
750
  end
703
751
 
704
752
  it "stops at the first play when input is received" do
705
- subject.should_receive(:stream_file).once.and_return(2)
753
+ expect(subject).to receive(:stream_file).once.and_return(2)
706
754
  digit = subject.interruptible_play output1, output2
707
- digit.should be == 2
755
+ expect(digit).to eq(2)
708
756
  end
709
757
 
710
758
  it "passes options on to #stream_file" do
711
- subject.should_receive(:stream_file).once.with(output1, '0123456789#*', extra_options)
712
- subject.should_receive(:stream_file).once.with(output2, '0123456789#*', extra_options)
759
+ expect(subject).to receive(:stream_file).once.with(output1, '0123456789#*', extra_options)
760
+ expect(subject).to receive(:stream_file).once.with(output2, '0123456789#*', extra_options)
713
761
  digit = subject.interruptible_play output1, output2, extra_options
714
- digit.should be_nil
762
+ expect(digit).to be_nil
715
763
  end
716
764
 
717
765
  it 'raises an exception when output is unsuccessful' do
718
- subject.should_receive(:stream_file).once.and_raise Output::PlaybackError, "Output failed"
766
+ expect(subject).to receive(:stream_file).once.and_raise Output::PlaybackError, "Output failed"
719
767
  expect { subject.interruptible_play non_existing }.to raise_error(Output::PlaybackError)
720
768
  end
721
769
  end
@@ -755,7 +803,7 @@ module Adhearsion
755
803
 
756
804
  #test does pass and method works, but not sure if the empty method is a good idea
757
805
  it "plays the correct output" do
758
- controller.stub(:write_and_await_response)
806
+ allow(controller).to receive(:write_and_await_response)
759
807
 
760
808
  expect_component_complete_event
761
809
  expect_component_execution Punchblock::Component::Output.new(:ssml => ssml)
@@ -763,23 +811,23 @@ module Adhearsion
763
811
  end
764
812
 
765
813
  it "returns a single digit amongst the allowed when pressed" do
766
- controller.should_receive(:write_and_await_response).with(kind_of(Punchblock::Component::Input)) do |input_component|
814
+ expect(controller).to receive(:write_and_await_response).with(kind_of(Punchblock::Component::Input)) do |input_component|
767
815
  input_component.trigger_event_handler Punchblock::Event::Complete.new
768
816
  end
769
817
 
770
- controller.should_receive(:write_and_await_response).once.with(kind_of(Punchblock::Component::Output))
818
+ expect(controller).to receive(:write_and_await_response).once.with(kind_of(Punchblock::Component::Output))
771
819
 
772
- Punchblock::Component::Output.any_instance.should_receive(:stop!)
773
- Punchblock::Component::Output.any_instance.should_receive(:complete_event).and_return double('complete', reason: double('Reason'))
820
+ expect_any_instance_of(Punchblock::Component::Output).to receive(:stop!)
821
+ expect_any_instance_of(Punchblock::Component::Output).to receive(:complete_event).and_return double('complete', reason: double('Reason'))
774
822
  expect_input_component_complete_event 'dtmf-5'
775
823
 
776
- subject.stream_file(prompt, allowed_digits).should be == '5'
824
+ expect(subject.stream_file(prompt, allowed_digits)).to eq('5')
777
825
  end
778
826
 
779
827
  context "with output options passed in" do
780
828
  let(:extra_options) { {renderer: :native } }
781
829
  it "plays the correct output with options" do
782
- controller.stub(:write_and_await_response)
830
+ allow(controller).to receive(:write_and_await_response)
783
831
 
784
832
  expect_component_complete_event
785
833
  expect_component_execution Punchblock::Component::Output.new({:ssml => ssml}.merge(extra_options))
@@ -799,7 +847,7 @@ module Adhearsion
799
847
  it 'plays the correct SSML' do
800
848
  ssml = RubySpeech::SSML.draw { string "Hello world" }
801
849
  expect_ssml_output ssml
802
- subject.say(ssml).should be_a Punchblock::Component::Output
850
+ expect(subject.say(ssml)).to be_a Punchblock::Component::Output
803
851
  end
804
852
  end
805
853
 
@@ -808,7 +856,7 @@ module Adhearsion
808
856
  str = "Hello world"
809
857
  ssml = RubySpeech::SSML.draw { string str }
810
858
  expect_ssml_output ssml
811
- subject.say(str).should be_a Punchblock::Component::Output
859
+ expect(subject.say(str)).to be_a Punchblock::Component::Output
812
860
  end
813
861
  end
814
862
 
@@ -881,14 +929,14 @@ module Adhearsion
881
929
  argument = 123
882
930
  ssml = RubySpeech::SSML.draw { string '123' }
883
931
  expect_ssml_output ssml
884
- subject.say(argument).should be_a Punchblock::Component::Output
932
+ expect(subject.say(argument)).to be_a Punchblock::Component::Output
885
933
  end
886
934
  end
887
935
  end
888
936
 
889
937
  describe "#speak" do
890
938
  it "should be an alias for #say" do
891
- subject.method(:speak).should be == subject.method(:say)
939
+ expect(subject.method(:speak)).to eq(subject.method(:say))
892
940
  end
893
941
  end
894
942
 
@@ -903,7 +951,7 @@ module Adhearsion
903
951
  it 'plays the correct SSML' do
904
952
  ssml = RubySpeech::SSML.draw { string "Hello world" }
905
953
  expect_async_ssml_output ssml
906
- subject.say!(ssml).should be_a Punchblock::Component::Output
954
+ expect(subject.say!(ssml)).to be_a Punchblock::Component::Output
907
955
  end
908
956
  end
909
957
 
@@ -912,7 +960,7 @@ module Adhearsion
912
960
  str = "Hello world"
913
961
  ssml = RubySpeech::SSML.draw { string str }
914
962
  expect_async_ssml_output ssml
915
- subject.say!(str).should be_a Punchblock::Component::Output
963
+ expect(subject.say!(str)).to be_a Punchblock::Component::Output
916
964
  end
917
965
  end
918
966
 
@@ -985,14 +1033,14 @@ module Adhearsion
985
1033
  argument = 123
986
1034
  ssml = RubySpeech::SSML.draw { string '123' }
987
1035
  expect_async_ssml_output ssml
988
- subject.say!(argument).should be_a Punchblock::Component::Output
1036
+ expect(subject.say!(argument)).to be_a Punchblock::Component::Output
989
1037
  end
990
1038
  end
991
1039
  end
992
1040
 
993
1041
  describe "#speak!" do
994
1042
  it "should be an alias for #say!" do
995
- subject.method(:speak!).should be == subject.method(:say!)
1043
+ expect(subject.method(:speak!)).to eq(subject.method(:say!))
996
1044
  end
997
1045
  end
998
1046
 
@@ -1006,7 +1054,7 @@ module Adhearsion
1006
1054
 
1007
1055
  it 'plays the correct ssml' do
1008
1056
  expect_ssml_output ssml
1009
- subject.say_characters('1234#abc').should be true
1057
+ expect(subject.say_characters('1234#abc')).to be true
1010
1058
  end
1011
1059
  end
1012
1060
 
@@ -1019,7 +1067,7 @@ module Adhearsion
1019
1067
 
1020
1068
  it 'plays the correct ssml' do
1021
1069
  expect_ssml_output ssml
1022
- subject.say_characters(1234).should be true
1070
+ expect(subject.say_characters(1234)).to be true
1023
1071
  end
1024
1072
  end
1025
1073
  end
@@ -1034,7 +1082,7 @@ module Adhearsion
1034
1082
 
1035
1083
  it 'plays the correct ssml' do
1036
1084
  expect_async_ssml_output ssml
1037
- subject.say_characters!('1234#abc').should be_a Punchblock::Component::Output
1085
+ expect(subject.say_characters!('1234#abc')).to be_a Punchblock::Component::Output
1038
1086
  end
1039
1087
  end
1040
1088
 
@@ -1047,7 +1095,7 @@ module Adhearsion
1047
1095
 
1048
1096
  it 'plays the correct ssml' do
1049
1097
  expect_async_ssml_output ssml
1050
- subject.say_characters!(1234).should be_a Punchblock::Component::Output
1098
+ expect(subject.say_characters!(1234)).to be_a Punchblock::Component::Output
1051
1099
  end
1052
1100
  end
1053
1101
  end