adhearsion 2.6.4 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -9
- data/CHANGELOG.md +22 -7
- data/Gemfile +2 -0
- data/README.markdown +4 -5
- data/Rakefile +1 -2
- data/adhearsion.gemspec +19 -8
- data/features/cli_create.feature +19 -3
- data/features/step_definitions/cli_steps.rb +0 -11
- data/features/support/env.rb +3 -4
- data/lib/adhearsion.rb +48 -27
- data/lib/adhearsion/call.rb +34 -50
- data/lib/adhearsion/call_controller.rb +6 -12
- data/lib/adhearsion/call_controller/dial.rb +15 -53
- data/lib/adhearsion/call_controller/input.rb +39 -162
- data/lib/adhearsion/call_controller/input/ask_grammar_builder.rb +44 -0
- data/lib/adhearsion/call_controller/input/menu_builder.rb +136 -0
- data/lib/adhearsion/call_controller/input/prompt_builder.rb +78 -0
- data/lib/adhearsion/call_controller/input/result.rb +46 -0
- data/lib/adhearsion/call_controller/output.rb +48 -67
- data/lib/adhearsion/call_controller/output/abstract_player.rb +3 -3
- data/lib/adhearsion/call_controller/output/async_player.rb +3 -3
- data/lib/adhearsion/call_controller/output/player.rb +1 -1
- data/lib/adhearsion/call_controller/record.rb +23 -8
- data/lib/adhearsion/calls.rb +1 -1
- data/lib/adhearsion/cli_commands/ahn_command.rb +2 -65
- data/lib/adhearsion/cli_commands/thor_errors.rb +0 -6
- data/lib/adhearsion/configuration.rb +91 -39
- data/lib/adhearsion/core_ext/blather/stanza.rb +41 -0
- data/lib/adhearsion/core_ext/blather/stanza/presence.rb +13 -0
- data/lib/adhearsion/error.rb +5 -0
- data/lib/adhearsion/event.rb +21 -0
- data/lib/adhearsion/event/active_speaker.rb +11 -0
- data/lib/adhearsion/event/answered.rb +11 -0
- data/lib/adhearsion/event/asterisk.rb +10 -0
- data/lib/adhearsion/event/asterisk/ami.rb +34 -0
- data/lib/adhearsion/event/complete.rb +75 -0
- data/lib/adhearsion/event/dtmf.rb +11 -0
- data/lib/adhearsion/event/end.rb +22 -0
- data/lib/adhearsion/event/input_timers_started.rb +9 -0
- data/lib/adhearsion/event/joined.rb +17 -0
- data/lib/adhearsion/event/offer.rb +14 -0
- data/lib/adhearsion/event/ringing.rb +11 -0
- data/lib/adhearsion/event/started_speaking.rb +13 -0
- data/lib/adhearsion/event/stopped_speaking.rb +13 -0
- data/lib/adhearsion/event/unjoined.rb +17 -0
- data/lib/adhearsion/events.rb +47 -66
- data/lib/adhearsion/foundation.rb +0 -1
- data/lib/adhearsion/foundation/object.rb +0 -5
- data/lib/adhearsion/generators/app/app_generator.rb +4 -1
- data/lib/adhearsion/generators/app/templates/Gemfile.erb +2 -10
- data/lib/adhearsion/generators/app/templates/adhearsion.erb +9 -9
- data/lib/adhearsion/generators/app/templates/config.ru +7 -0
- data/lib/adhearsion/generators/app/templates/en.yml +4 -0
- data/lib/adhearsion/generators/app/templates/events.erb +2 -2
- data/lib/adhearsion/generators/app/templates/hello_world.wav +0 -0
- data/lib/adhearsion/generators/app/templates/simon_game.rb +2 -1
- data/lib/adhearsion/generators/app/templates/simon_game_spec.rb +2 -2
- data/lib/adhearsion/has_headers.rb +34 -0
- data/lib/adhearsion/http_server.rb +37 -0
- data/lib/adhearsion/initializer.rb +19 -153
- data/lib/adhearsion/logging.rb +6 -25
- data/lib/adhearsion/outbound_call.rb +5 -5
- data/lib/adhearsion/plugin.rb +1 -0
- data/lib/adhearsion/protocol_error.rb +26 -0
- data/lib/adhearsion/rayo.rb +30 -0
- data/lib/adhearsion/rayo/client.rb +62 -0
- data/lib/adhearsion/rayo/client/component_registry.rb +33 -0
- data/lib/adhearsion/rayo/command.rb +21 -0
- data/lib/adhearsion/rayo/command/accept.rb +16 -0
- data/lib/adhearsion/rayo/command/answer.rb +16 -0
- data/lib/adhearsion/rayo/command/dial.rb +57 -0
- data/lib/adhearsion/rayo/command/hangup.rb +16 -0
- data/lib/adhearsion/rayo/command/join.rb +43 -0
- data/lib/adhearsion/rayo/command/mute.rb +13 -0
- data/lib/adhearsion/rayo/command/redirect.rb +23 -0
- data/lib/adhearsion/rayo/command/reject.rb +40 -0
- data/lib/adhearsion/rayo/command/unjoin.rb +24 -0
- data/lib/adhearsion/rayo/command/unmute.rb +13 -0
- data/lib/adhearsion/rayo/command_node.rb +47 -0
- data/lib/adhearsion/rayo/component.rb +21 -0
- data/lib/adhearsion/rayo/component/asterisk.rb +13 -0
- data/lib/adhearsion/rayo/component/asterisk/agi.rb +14 -0
- data/lib/adhearsion/rayo/component/asterisk/agi/command.rb +46 -0
- data/lib/adhearsion/rayo/component/asterisk/ami.rb +14 -0
- data/lib/adhearsion/rayo/component/asterisk/ami/action.rb +61 -0
- data/lib/adhearsion/rayo/component/component_node.rb +90 -0
- data/lib/adhearsion/rayo/component/input.rb +186 -0
- data/lib/adhearsion/rayo/component/output.rb +471 -0
- data/lib/adhearsion/rayo/component/prompt.rb +53 -0
- data/lib/adhearsion/rayo/component/receive_fax.rb +26 -0
- data/lib/adhearsion/rayo/component/record.rb +165 -0
- data/lib/adhearsion/rayo/component/send_fax.rb +64 -0
- data/lib/adhearsion/rayo/component/stop.rb +11 -0
- data/lib/adhearsion/rayo/connection.rb +12 -0
- data/lib/adhearsion/rayo/connection/asterisk.rb +74 -0
- data/lib/adhearsion/rayo/connection/connected.rb +22 -0
- data/lib/adhearsion/rayo/connection/generic_connection.rb +22 -0
- data/lib/adhearsion/rayo/connection/xmpp.rb +198 -0
- data/lib/adhearsion/rayo/disconnected_error.rb +22 -0
- data/lib/adhearsion/{punchblock_plugin → rayo}/initializer.rb +19 -19
- data/lib/adhearsion/rayo/rayo_node.rb +127 -0
- data/lib/adhearsion/rayo/ref.rb +57 -0
- data/lib/adhearsion/statistics.rb +1 -1
- data/lib/adhearsion/tasks.rb +1 -2
- data/lib/adhearsion/tasks/configuration.rb +1 -1
- data/lib/adhearsion/tasks/environment.rb +0 -2
- data/lib/adhearsion/tasks/i18n.rb +49 -0
- data/lib/adhearsion/translator.rb +11 -0
- data/lib/adhearsion/translator/asterisk.rb +234 -0
- data/lib/adhearsion/translator/asterisk/agi_app.rb +17 -0
- data/lib/adhearsion/translator/asterisk/agi_command.rb +45 -0
- data/lib/adhearsion/translator/asterisk/ami_error_converter.rb +20 -0
- data/lib/adhearsion/translator/asterisk/call.rb +416 -0
- data/lib/adhearsion/translator/asterisk/channel.rb +43 -0
- data/lib/adhearsion/translator/asterisk/component.rb +88 -0
- data/lib/adhearsion/translator/asterisk/component/asterisk.rb +15 -0
- data/lib/adhearsion/translator/asterisk/component/asterisk/agi_command.rb +42 -0
- data/lib/adhearsion/translator/asterisk/component/asterisk/ami_action.rb +68 -0
- data/lib/adhearsion/translator/asterisk/component/composed_prompt.rb +76 -0
- data/lib/adhearsion/translator/asterisk/component/dtmf_recognizer.rb +137 -0
- data/lib/adhearsion/translator/asterisk/component/input.rb +34 -0
- data/lib/adhearsion/translator/asterisk/component/input_component.rb +90 -0
- data/lib/adhearsion/translator/asterisk/component/mrcp_native_prompt.rb +71 -0
- data/lib/adhearsion/translator/asterisk/component/mrcp_prompt.rb +55 -0
- data/lib/adhearsion/translator/asterisk/component/mrcp_recog_prompt.rb +165 -0
- data/lib/adhearsion/translator/asterisk/component/output.rb +233 -0
- data/lib/adhearsion/translator/asterisk/component/record.rb +101 -0
- data/lib/adhearsion/translator/asterisk/component/stop_by_redirect.rb +30 -0
- data/lib/adhearsion/translator/asterisk/unimrcp_app.rb +28 -0
- data/lib/adhearsion/uri_list.rb +21 -0
- data/lib/adhearsion/version.rb +1 -1
- data/spec/adhearsion/call_controller/dial_spec.rb +79 -1420
- data/spec/adhearsion/call_controller/input_spec.rb +1141 -237
- data/spec/adhearsion/call_controller/output/async_player_spec.rb +10 -10
- data/spec/adhearsion/call_controller/output/player_spec.rb +8 -8
- data/spec/adhearsion/call_controller/output_spec.rb +162 -215
- data/spec/adhearsion/call_controller/record_spec.rb +15 -16
- data/spec/adhearsion/call_controller_spec.rb +23 -40
- data/spec/adhearsion/call_spec.rb +123 -129
- data/spec/adhearsion/calls_spec.rb +3 -3
- data/spec/adhearsion/configuration_spec.rb +94 -108
- data/spec/adhearsion/event/answered_spec.rb +50 -0
- data/spec/adhearsion/event/asterisk/Find Results +402 -0
- data/spec/adhearsion/event/asterisk/ami_spec.rb +81 -0
- data/spec/adhearsion/event/complete_spec.rb +176 -0
- data/spec/adhearsion/event/dtmf_spec.rb +35 -0
- data/spec/adhearsion/event/end_spec.rb +85 -0
- data/spec/adhearsion/event/input_timers_started_spec.rb +19 -0
- data/spec/adhearsion/event/joined_spec.rb +53 -0
- data/spec/adhearsion/event/offer_spec.rb +106 -0
- data/spec/adhearsion/event/ringing_spec.rb +50 -0
- data/spec/adhearsion/event/started_speaking_spec.rb +37 -0
- data/spec/adhearsion/event/stopped_speaking_spec.rb +37 -0
- data/spec/adhearsion/event/unjoined_spec.rb +48 -0
- data/spec/adhearsion/event/untitled +0 -0
- data/spec/adhearsion/events_spec.rb +19 -45
- data/spec/adhearsion/initializer_spec.rb +12 -184
- data/spec/adhearsion/logging_spec.rb +5 -20
- data/spec/adhearsion/outbound_call_spec.rb +13 -13
- data/spec/adhearsion/plugin_spec.rb +3 -4
- data/spec/adhearsion/protocol_error_spec.rb +91 -0
- data/spec/adhearsion/rayo/client/component_registry_spec.rb +26 -0
- data/spec/adhearsion/rayo/client_spec.rb +134 -0
- data/spec/adhearsion/rayo/command/accept_spec.rb +63 -0
- data/spec/adhearsion/rayo/command/answer_spec.rb +73 -0
- data/spec/adhearsion/rayo/command/dial_spec.rb +156 -0
- data/spec/adhearsion/rayo/command/hangup_spec.rb +63 -0
- data/spec/adhearsion/rayo/command/join_spec.rb +158 -0
- data/spec/adhearsion/rayo/command/mute_spec.rb +32 -0
- data/spec/adhearsion/rayo/command/redirect_spec.rb +89 -0
- data/spec/adhearsion/rayo/command/reject_spec.rb +117 -0
- data/spec/adhearsion/rayo/command/unjoin_spec.rb +82 -0
- data/spec/adhearsion/rayo/command/unmute_spec.rb +32 -0
- data/spec/adhearsion/rayo/command_node_spec.rb +101 -0
- data/spec/adhearsion/rayo/component/asterisk/agi/command_spec.rb +111 -0
- data/spec/adhearsion/rayo/component/asterisk/ami/action_spec.rb +173 -0
- data/spec/adhearsion/rayo/component/component_node_spec.rb +110 -0
- data/spec/adhearsion/rayo/component/input_spec.rb +715 -0
- data/spec/adhearsion/rayo/component/output_spec.rb +1030 -0
- data/spec/adhearsion/rayo/component/prompt_spec.rb +171 -0
- data/spec/adhearsion/rayo/component/receive_fax_spec.rb +136 -0
- data/spec/adhearsion/rayo/component/record_spec.rb +497 -0
- data/spec/adhearsion/rayo/component/send_fax_spec.rb +144 -0
- data/spec/adhearsion/rayo/connection/asterisk_spec.rb +118 -0
- data/spec/adhearsion/rayo/connection/xmpp_spec.rb +449 -0
- data/spec/adhearsion/rayo/initializer_spec.rb +353 -0
- data/spec/adhearsion/rayo/ref_spec.rb +168 -0
- data/spec/adhearsion/rayo_spec.rb +7 -0
- data/spec/adhearsion/router/route_spec.rb +1 -1
- data/spec/adhearsion/statistics_spec.rb +2 -5
- data/spec/adhearsion/translator/asterisk/call_spec.rb +2047 -0
- data/spec/adhearsion/translator/asterisk/component/asterisk/agi_command_spec.rb +256 -0
- data/spec/adhearsion/translator/asterisk/component/asterisk/ami_action_spec.rb +151 -0
- data/spec/adhearsion/translator/asterisk/component/composed_prompt_spec.rb +257 -0
- data/spec/adhearsion/translator/asterisk/component/input_spec.rb +571 -0
- data/spec/adhearsion/translator/asterisk/component/mrcp_native_prompt_spec.rb +774 -0
- data/spec/adhearsion/translator/asterisk/component/mrcp_prompt_spec.rb +1244 -0
- data/spec/adhearsion/translator/asterisk/component/output_spec.rb +1850 -0
- data/spec/adhearsion/translator/asterisk/component/record_spec.rb +426 -0
- data/spec/adhearsion/translator/asterisk/component/stop_by_redirect_spec.rb +62 -0
- data/spec/adhearsion/translator/asterisk/component_spec.rb +83 -0
- data/spec/adhearsion/translator/asterisk_spec.rb +685 -0
- data/spec/adhearsion/uri_list_spec.rb +88 -0
- data/spec/adhearsion_spec.rb +89 -14
- data/spec/fixtures/locale/en.yml +13 -0
- data/spec/fixtures/locale/it.yml +13 -0
- data/spec/spec_helper.rb +18 -5
- data/spec/support/call_controller_test_helpers.rb +3 -2
- data/spec/support/initializer_stubs.rb +3 -1
- data/spec/support/punchblock_examples.rb +65 -0
- data/spec/support/punchblock_mocks.rb +12 -0
- metadata +412 -70
- data/features/cli_daemon.feature +0 -20
- data/features/cli_restart.feature +0 -52
- data/features/cli_stop.feature +0 -50
- data/lib/adhearsion/call_controller/menu_dsl.rb +0 -21
- data/lib/adhearsion/call_controller/menu_dsl/array_match_calculator.rb +0 -26
- data/lib/adhearsion/call_controller/menu_dsl/calculated_match.rb +0 -43
- data/lib/adhearsion/call_controller/menu_dsl/calculated_match_collection.rb +0 -45
- data/lib/adhearsion/call_controller/menu_dsl/fixnum_match_calculator.rb +0 -11
- data/lib/adhearsion/call_controller/menu_dsl/match_calculator.rb +0 -40
- data/lib/adhearsion/call_controller/menu_dsl/menu.rb +0 -207
- data/lib/adhearsion/call_controller/menu_dsl/menu_builder.rb +0 -92
- data/lib/adhearsion/call_controller/menu_dsl/range_match_calculator.rb +0 -60
- data/lib/adhearsion/call_controller/menu_dsl/string_match_calculator.rb +0 -25
- data/lib/adhearsion/call_controller/utility.rb +0 -77
- data/lib/adhearsion/foundation/custom_daemonizer.rb +0 -52
- data/lib/adhearsion/punchblock_plugin.rb +0 -63
- data/scripts/cloc-1.64.pl +0 -10483
- data/spec/adhearsion/call_controller/menu_dsl/array_match_calculator_spec.rb +0 -76
- data/spec/adhearsion/call_controller/menu_dsl/calculated_match_collection_spec.rb +0 -60
- data/spec/adhearsion/call_controller/menu_dsl/calculated_match_spec.rb +0 -61
- data/spec/adhearsion/call_controller/menu_dsl/fixnum_match_calculator_spec.rb +0 -39
- data/spec/adhearsion/call_controller/menu_dsl/match_calculator_spec.rb +0 -17
- data/spec/adhearsion/call_controller/menu_dsl/menu_builder_spec.rb +0 -165
- data/spec/adhearsion/call_controller/menu_dsl/menu_spec.rb +0 -420
- data/spec/adhearsion/call_controller/menu_dsl/range_match_calculator_spec.rb +0 -32
- data/spec/adhearsion/call_controller/menu_dsl/string_match_calculator_spec.rb +0 -40
- data/spec/adhearsion/call_controller/utility_spec.rb +0 -90
- data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +0 -356
- data/spec/adhearsion/punchblock_plugin_spec.rb +0 -59
@@ -17,32 +17,32 @@ module Adhearsion
|
|
17
17
|
let(:content) { RubySpeech::SSML.draw { string "BOO" } }
|
18
18
|
|
19
19
|
it "should execute an output component with the provided SSML content" do
|
20
|
-
component =
|
20
|
+
component = Adhearsion::Rayo::Component::Output.new :ssml => content
|
21
21
|
expect_message_waiting_for_response component
|
22
22
|
subject.output content
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should allow extra options to be passed to the output component" do
|
26
|
-
component =
|
26
|
+
component = Adhearsion::Rayo::Component::Output.new :ssml => content, :start_paused => true
|
27
27
|
expect_message_waiting_for_response component
|
28
28
|
subject.output content, :start_paused => true
|
29
29
|
end
|
30
30
|
|
31
31
|
it "returns the component" do
|
32
|
-
component =
|
32
|
+
component = Adhearsion::Rayo::Component::Output.new :ssml => content
|
33
33
|
expect_message_waiting_for_response component
|
34
|
-
expect(subject.output(content)).to be_a
|
34
|
+
expect(subject.output(content)).to be_a Adhearsion::Rayo::Component::Output
|
35
35
|
end
|
36
36
|
|
37
37
|
it "raises a PlaybackError if the component fails to start" do
|
38
|
-
expect_message_waiting_for_response
|
38
|
+
expect_message_waiting_for_response Adhearsion::Rayo::Component::Output.new(:ssml => content), Adhearsion::ProtocolError
|
39
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
|
-
response =
|
44
|
-
response.reason =
|
45
|
-
component =
|
43
|
+
response = Adhearsion::Event::Complete.new
|
44
|
+
response.reason = Adhearsion::Event::Complete::Error.new
|
45
|
+
component = Adhearsion::Rayo::Component::Output.new(:ssml => content)
|
46
46
|
allow(subject).to receive_messages :new_output => component
|
47
47
|
expect_message_waiting_for_response component
|
48
48
|
expect(controller.logger).to receive(:error).once
|
@@ -57,7 +57,7 @@ module Adhearsion
|
|
57
57
|
let(:ssml) { RubySpeech::SSML.draw { string "BOO" } }
|
58
58
|
|
59
59
|
it 'executes an Output with the correct ssml' do
|
60
|
-
component =
|
60
|
+
component = Adhearsion::Rayo::Component::Output.new :ssml => ssml
|
61
61
|
expect_message_waiting_for_response component
|
62
62
|
subject.play_ssml ssml
|
63
63
|
end
|
@@ -67,7 +67,7 @@ module Adhearsion
|
|
67
67
|
let(:url) { "http://example.com/ex.ssml" }
|
68
68
|
|
69
69
|
it 'executes an Output with the URL' do
|
70
|
-
component =
|
70
|
+
component = Adhearsion::Rayo::Component::Output.new({render_document: {value: url, content_type: "application/ssml+xml"}})
|
71
71
|
expect_message_waiting_for_response component
|
72
72
|
subject.play_url url
|
73
73
|
end
|
@@ -17,18 +17,18 @@ module Adhearsion
|
|
17
17
|
let(:content) { RubySpeech::SSML.draw { string "BOO" } }
|
18
18
|
|
19
19
|
it "should execute an output component with the provided SSML content" do
|
20
|
-
expect_component_execution
|
20
|
+
expect_component_execution Adhearsion::Rayo::Component::Output.new(:ssml => content)
|
21
21
|
subject.output content
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should allow extra options to be passed to the output component" do
|
25
|
-
component =
|
25
|
+
component = Adhearsion::Rayo::Component::Output.new :ssml => content, :start_paused => true
|
26
26
|
expect_component_execution component
|
27
27
|
subject.output content, :start_paused => true
|
28
28
|
end
|
29
29
|
|
30
30
|
it "yields the component to the block before waiting for it to finish" do
|
31
|
-
component =
|
31
|
+
component = Adhearsion::Rayo::Component::Output.new :ssml => content
|
32
32
|
|
33
33
|
expect(controller).to receive(:execute_component_and_await_completion).once.with(component).and_yield(:foo)
|
34
34
|
|
@@ -42,17 +42,17 @@ module Adhearsion
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "raises a PlaybackError if the component fails to start" do
|
45
|
-
expect_component_execution
|
45
|
+
expect_component_execution Adhearsion::Rayo::Component::Output.new(:ssml => content), Adhearsion::ProtocolError
|
46
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
|
-
expect_component_execution
|
50
|
+
expect_component_execution Adhearsion::Rayo::Component::Output.new(:ssml => content), Adhearsion::Error
|
51
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
|
-
expect_component_execution
|
55
|
+
expect_component_execution Adhearsion::Rayo::Component::Output.new(:ssml => content), Call::Hangup
|
56
56
|
expect { subject.output content }.to raise_error(Call::Hangup)
|
57
57
|
end
|
58
58
|
end
|
@@ -61,7 +61,7 @@ module Adhearsion
|
|
61
61
|
let(:ssml) { RubySpeech::SSML.draw { string "BOO" } }
|
62
62
|
|
63
63
|
it 'executes an Output with the correct ssml' do
|
64
|
-
expect_component_execution
|
64
|
+
expect_component_execution Adhearsion::Rayo::Component::Output.new(:ssml => ssml)
|
65
65
|
subject.play_ssml ssml
|
66
66
|
end
|
67
67
|
end
|
@@ -70,7 +70,7 @@ module Adhearsion
|
|
70
70
|
let(:url) { "http://example.com/ex.ssml" }
|
71
71
|
|
72
72
|
it 'executes an Output with the URL' do
|
73
|
-
component =
|
73
|
+
component = Adhearsion::Rayo::Component::Output.new({render_document: {value: url, content_type: "application/ssml+xml"}})
|
74
74
|
expect_component_execution component
|
75
75
|
subject.play_url url
|
76
76
|
end
|
@@ -9,20 +9,20 @@ module Adhearsion
|
|
9
9
|
include CallControllerTestHelpers
|
10
10
|
|
11
11
|
def expect_ssml_output(ssml, options = {})
|
12
|
-
expect_component_execution
|
12
|
+
expect_component_execution Adhearsion::Rayo::Component::Output.new(options.merge(:ssml => ssml))
|
13
13
|
end
|
14
14
|
|
15
15
|
def expect_async_ssml_output(ssml, options = {})
|
16
|
-
expect_message_waiting_for_response
|
16
|
+
expect_message_waiting_for_response Adhearsion::Rayo::Component::Output.new(options.merge(:ssml => ssml))
|
17
17
|
end
|
18
18
|
|
19
19
|
def expect_url_output(url, options = {})
|
20
|
-
component =
|
20
|
+
component = Adhearsion::Rayo::Component::Output.new(options.merge(render_document: {value: url, content_type: "application/ssml+xml"}))
|
21
21
|
expect_component_execution component
|
22
22
|
end
|
23
23
|
|
24
24
|
def expect_async_url_output(url, options = {})
|
25
|
-
component =
|
25
|
+
component = Adhearsion::Rayo::Component::Output.new(options.merge(render_document: {value: url, content_type: "application/ssml+xml"}))
|
26
26
|
expect_message_waiting_for_response component
|
27
27
|
end
|
28
28
|
|
@@ -73,10 +73,10 @@ module Adhearsion
|
|
73
73
|
end
|
74
74
|
|
75
75
|
context "with a media engine" do
|
76
|
-
let(:
|
76
|
+
let(:renderer) { :native }
|
77
77
|
it "should use the specified media engine in the component" do
|
78
|
-
expect_ssml_output ssml, renderer:
|
79
|
-
expect(subject.play_audio(audio_file, renderer:
|
78
|
+
expect_ssml_output ssml, renderer: renderer
|
79
|
+
expect(subject.play_audio(audio_file, renderer: renderer)).to be true
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -91,7 +91,7 @@ module Adhearsion
|
|
91
91
|
|
92
92
|
it 'plays the correct ssml' do
|
93
93
|
expect_async_ssml_output ssml
|
94
|
-
expect(subject.play_audio!(audio_file)).to be_a
|
94
|
+
expect(subject.play_audio!(audio_file)).to be_a Adhearsion::Rayo::Component::Output
|
95
95
|
end
|
96
96
|
|
97
97
|
context "with a fallback" do
|
@@ -107,15 +107,15 @@ module Adhearsion
|
|
107
107
|
|
108
108
|
it 'places the fallback in the SSML doc' do
|
109
109
|
expect_async_ssml_output ssml
|
110
|
-
expect(subject.play_audio!(audio_file, :fallback => fallback)).to be_a
|
110
|
+
expect(subject.play_audio!(audio_file, :fallback => fallback)).to be_a Adhearsion::Rayo::Component::Output
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
context "with a
|
115
|
-
let(:
|
116
|
-
it "should use the specified
|
117
|
-
expect_async_ssml_output ssml, renderer:
|
118
|
-
expect(subject.play_audio!(audio_file, renderer:
|
114
|
+
context "with a renderer" do
|
115
|
+
let(:renderer) { :native }
|
116
|
+
it "should use the specified renderer in the output component" do
|
117
|
+
expect_async_ssml_output ssml, renderer: renderer
|
118
|
+
expect(subject.play_audio!(audio_file, renderer: renderer)).to be_a Adhearsion::Rayo::Component::Output
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -176,7 +176,7 @@ module Adhearsion
|
|
176
176
|
|
177
177
|
it 'plays the correct ssml' do
|
178
178
|
expect_async_ssml_output ssml
|
179
|
-
expect(subject.play_numeric!(input)).to be_a
|
179
|
+
expect(subject.play_numeric!(input)).to be_a Adhearsion::Rayo::Component::Output
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -185,7 +185,7 @@ module Adhearsion
|
|
185
185
|
|
186
186
|
it 'plays the correct ssml' do
|
187
187
|
expect_async_ssml_output ssml
|
188
|
-
expect(subject.play_numeric!(input)).to be_a
|
188
|
+
expect(subject.play_numeric!(input)).to be_a Adhearsion::Rayo::Component::Output
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
@@ -203,7 +203,7 @@ module Adhearsion
|
|
203
203
|
|
204
204
|
it "should use the specified renderer in the SSML" do
|
205
205
|
expect_async_ssml_output ssml, renderer: renderer
|
206
|
-
expect(subject.play_numeric!(input, renderer: renderer)).to be_a
|
206
|
+
expect(subject.play_numeric!(input, renderer: renderer)).to be_a Adhearsion::Rayo::Component::Output
|
207
207
|
end
|
208
208
|
end
|
209
209
|
end
|
@@ -233,7 +233,7 @@ module Adhearsion
|
|
233
233
|
|
234
234
|
it 'plays the url' do
|
235
235
|
expect_async_url_output input
|
236
|
-
expect(subject.play_document!(input)).to be_a
|
236
|
+
expect(subject.play_document!(input)).to be_a Adhearsion::Rayo::Component::Output
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
@@ -347,7 +347,7 @@ module Adhearsion
|
|
347
347
|
|
348
348
|
it 'plays the correct SSML' do
|
349
349
|
expect_async_ssml_output ssml
|
350
|
-
expect(subject.play_time!(input)).to be_a
|
350
|
+
expect(subject.play_time!(input)).to be_a Adhearsion::Rayo::Component::Output
|
351
351
|
end
|
352
352
|
end
|
353
353
|
|
@@ -357,7 +357,7 @@ module Adhearsion
|
|
357
357
|
|
358
358
|
it 'plays the correct SSML' do
|
359
359
|
expect_async_ssml_output ssml
|
360
|
-
expect(subject.play_time!(input)).to be_a
|
360
|
+
expect(subject.play_time!(input)).to be_a Adhearsion::Rayo::Component::Output
|
361
361
|
end
|
362
362
|
end
|
363
363
|
|
@@ -368,7 +368,7 @@ module Adhearsion
|
|
368
368
|
|
369
369
|
it 'plays the correct SSML' do
|
370
370
|
expect_async_ssml_output ssml
|
371
|
-
expect(subject.play_time!(input, :format => format)).to be_a
|
371
|
+
expect(subject.play_time!(input, :format => format)).to be_a Adhearsion::Rayo::Component::Output
|
372
372
|
end
|
373
373
|
end
|
374
374
|
|
@@ -380,7 +380,7 @@ module Adhearsion
|
|
380
380
|
|
381
381
|
it 'plays the correct SSML' do
|
382
382
|
expect_async_ssml_output ssml
|
383
|
-
expect(subject.play_time!(base_input, :strftime => strftime)).to be_a
|
383
|
+
expect(subject.play_time!(base_input, :strftime => strftime)).to be_a Adhearsion::Rayo::Component::Output
|
384
384
|
end
|
385
385
|
end
|
386
386
|
|
@@ -393,7 +393,7 @@ module Adhearsion
|
|
393
393
|
|
394
394
|
it 'plays the correct SSML' do
|
395
395
|
expect_async_ssml_output ssml
|
396
|
-
expect(subject.play_time!(base_input, :format => format, :strftime => strftime)).to be_a
|
396
|
+
expect(subject.play_time!(base_input, :format => format, :strftime => strftime)).to be_a Adhearsion::Rayo::Component::Output
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
@@ -405,7 +405,7 @@ module Adhearsion
|
|
405
405
|
|
406
406
|
it "should use the specified renderer in the SSML" do
|
407
407
|
expect_async_ssml_output ssml, renderer: renderer
|
408
|
-
expect(subject.play_time!(input, format: format, renderer: renderer)).to be_a
|
408
|
+
expect(subject.play_time!(input, format: format, renderer: renderer)).to be_a Adhearsion::Rayo::Component::Output
|
409
409
|
end
|
410
410
|
end
|
411
411
|
|
@@ -611,7 +611,7 @@ module Adhearsion
|
|
611
611
|
|
612
612
|
it 'plays the audio file' do
|
613
613
|
expect_async_ssml_output ssml
|
614
|
-
expect(subject.play!(audio_file)).to be_a
|
614
|
+
expect(subject.play!(audio_file)).to be_a Adhearsion::Rayo::Component::Output
|
615
615
|
end
|
616
616
|
|
617
617
|
it 'plays the audio file with the specified extra options if present' do
|
@@ -635,7 +635,7 @@ module Adhearsion
|
|
635
635
|
|
636
636
|
it 'plays all arguments in one document' do
|
637
637
|
expect_async_ssml_output ssml
|
638
|
-
expect(subject.play!(*args)).to be_a
|
638
|
+
expect(subject.play!(*args)).to be_a Adhearsion::Rayo::Component::Output
|
639
639
|
end
|
640
640
|
|
641
641
|
it 'plays all arguments in one document with the extra options if present' do
|
@@ -657,7 +657,7 @@ module Adhearsion
|
|
657
657
|
|
658
658
|
it 'plays the number' do
|
659
659
|
expect_async_ssml_output ssml
|
660
|
-
expect(subject.play!(argument)).to be_a
|
660
|
+
expect(subject.play!(argument)).to be_a Adhearsion::Rayo::Component::Output
|
661
661
|
end
|
662
662
|
end
|
663
663
|
|
@@ -673,7 +673,7 @@ module Adhearsion
|
|
673
673
|
|
674
674
|
it 'plays the number' do
|
675
675
|
expect_async_ssml_output ssml
|
676
|
-
expect(subject.play!(argument)).to be_a
|
676
|
+
expect(subject.play!(argument)).to be_a Adhearsion::Rayo::Component::Output
|
677
677
|
end
|
678
678
|
end
|
679
679
|
|
@@ -689,7 +689,7 @@ module Adhearsion
|
|
689
689
|
|
690
690
|
it 'plays the time' do
|
691
691
|
expect_async_ssml_output ssml
|
692
|
-
expect(subject.play!(time)).to be_a
|
692
|
+
expect(subject.play!(time)).to be_a Adhearsion::Rayo::Component::Output
|
693
693
|
end
|
694
694
|
end
|
695
695
|
|
@@ -704,7 +704,7 @@ module Adhearsion
|
|
704
704
|
|
705
705
|
it 'plays the time' do
|
706
706
|
expect_async_ssml_output ssml
|
707
|
-
expect(subject.play!(date)).to be_a
|
707
|
+
expect(subject.play!(date)).to be_a Adhearsion::Rayo::Component::Output
|
708
708
|
end
|
709
709
|
end
|
710
710
|
|
@@ -723,7 +723,7 @@ module Adhearsion
|
|
723
723
|
|
724
724
|
it 'plays the time with the specified format and strftime' do
|
725
725
|
expect_async_ssml_output ssml
|
726
|
-
expect(subject.play!(:value => date, :format => format, :strftime => strftime)).to be_a
|
726
|
+
expect(subject.play!(:value => date, :format => format, :strftime => strftime)).to be_a Adhearsion::Rayo::Component::Output
|
727
727
|
end
|
728
728
|
end
|
729
729
|
|
@@ -732,106 +732,7 @@ module Adhearsion
|
|
732
732
|
|
733
733
|
it "plays the SSML without generating" do
|
734
734
|
expect_async_ssml_output ssml
|
735
|
-
expect(subject.play!(ssml)).to be_a
|
736
|
-
end
|
737
|
-
end
|
738
|
-
end
|
739
|
-
|
740
|
-
describe "#interruptible_play" do
|
741
|
-
let(:output1) { "one two" }
|
742
|
-
let(:output2) { "three four" }
|
743
|
-
let(:non_existing) { "http://adhearsion.com/nonexistingfile.mp3" }
|
744
|
-
let(:extra_options) { {renderer: :native } }
|
745
|
-
|
746
|
-
it "plays two outputs in succession" do
|
747
|
-
expect(subject).to receive(:stream_file).twice
|
748
|
-
digit = subject.interruptible_play output1, output2
|
749
|
-
expect(digit).to be_nil
|
750
|
-
end
|
751
|
-
|
752
|
-
it "stops at the first play when input is received" do
|
753
|
-
expect(subject).to receive(:stream_file).once.and_return(2)
|
754
|
-
digit = subject.interruptible_play output1, output2
|
755
|
-
expect(digit).to eq(2)
|
756
|
-
end
|
757
|
-
|
758
|
-
it "passes options on to #stream_file" do
|
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)
|
761
|
-
digit = subject.interruptible_play output1, output2, extra_options
|
762
|
-
expect(digit).to be_nil
|
763
|
-
end
|
764
|
-
|
765
|
-
it 'raises an exception when output is unsuccessful' do
|
766
|
-
expect(subject).to receive(:stream_file).once.and_raise Output::PlaybackError, "Output failed"
|
767
|
-
expect { subject.interruptible_play non_existing }.to raise_error(Output::PlaybackError)
|
768
|
-
end
|
769
|
-
end
|
770
|
-
|
771
|
-
describe "#stream_file" do
|
772
|
-
let(:allowed_digits) { '35' }
|
773
|
-
let(:prompt) { "Press 3 or 5 to make something happen." }
|
774
|
-
|
775
|
-
let(:ssml) do
|
776
|
-
RubySpeech::SSML.draw do
|
777
|
-
string "Press 3 or 5 to make something happen."
|
778
|
-
end
|
779
|
-
end
|
780
|
-
|
781
|
-
let(:grammar) do
|
782
|
-
RubySpeech::GRXML.draw :mode => 'dtmf', :root => 'acceptdigits' do
|
783
|
-
rule id: 'acceptdigits' do
|
784
|
-
one_of do
|
785
|
-
allowed_digits.each { |d| item { d.to_s } }
|
786
|
-
end
|
787
|
-
end
|
788
|
-
end
|
789
|
-
end
|
790
|
-
|
791
|
-
let(:output_component) {
|
792
|
-
Punchblock::Component::Output.new :ssml => ssml.to_s
|
793
|
-
}
|
794
|
-
|
795
|
-
let(:input_component) {
|
796
|
-
Punchblock::Component::Input.new :mode => :dtmf,
|
797
|
-
:grammar => { :value => grammar.to_s }
|
798
|
-
}
|
799
|
-
|
800
|
-
def expect_component_complete_event
|
801
|
-
expect_input_component_complete_event 'dtmf-5'
|
802
|
-
end
|
803
|
-
|
804
|
-
#test does pass and method works, but not sure if the empty method is a good idea
|
805
|
-
it "plays the correct output" do
|
806
|
-
allow(controller).to receive(:write_and_await_response)
|
807
|
-
|
808
|
-
expect_component_complete_event
|
809
|
-
expect_component_execution Punchblock::Component::Output.new(:ssml => ssml)
|
810
|
-
subject.stream_file prompt, allowed_digits
|
811
|
-
end
|
812
|
-
|
813
|
-
it "returns a single digit amongst the allowed when pressed" do
|
814
|
-
expect(controller).to receive(:write_and_await_response).with(kind_of(Punchblock::Component::Input)) do |input_component|
|
815
|
-
input_component.trigger_event_handler Punchblock::Event::Complete.new
|
816
|
-
end
|
817
|
-
|
818
|
-
expect(controller).to receive(:write_and_await_response).once.with(kind_of(Punchblock::Component::Output))
|
819
|
-
|
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'))
|
822
|
-
expect_input_component_complete_event 'dtmf-5'
|
823
|
-
|
824
|
-
expect(subject.stream_file(prompt, allowed_digits)).to eq('5')
|
825
|
-
end
|
826
|
-
|
827
|
-
context "with output options passed in" do
|
828
|
-
let(:extra_options) { {renderer: :native } }
|
829
|
-
it "plays the correct output with options" do
|
830
|
-
allow(controller).to receive(:write_and_await_response)
|
831
|
-
|
832
|
-
expect_component_complete_event
|
833
|
-
expect_component_execution Punchblock::Component::Output.new({:ssml => ssml}.merge(extra_options))
|
834
|
-
subject.stream_file prompt, allowed_digits, extra_options
|
735
|
+
expect(subject.play!(ssml)).to be_a Adhearsion::Rayo::Component::Output
|
835
736
|
end
|
836
737
|
end
|
837
738
|
end
|
@@ -847,7 +748,7 @@ module Adhearsion
|
|
847
748
|
it 'plays the correct SSML' do
|
848
749
|
ssml = RubySpeech::SSML.draw { string "Hello world" }
|
849
750
|
expect_ssml_output ssml
|
850
|
-
expect(subject.say(ssml)).to be_a
|
751
|
+
expect(subject.say(ssml)).to be_a Adhearsion::Rayo::Component::Output
|
851
752
|
end
|
852
753
|
end
|
853
754
|
|
@@ -856,30 +757,16 @@ module Adhearsion
|
|
856
757
|
str = "Hello world"
|
857
758
|
ssml = RubySpeech::SSML.draw { string str }
|
858
759
|
expect_ssml_output ssml
|
859
|
-
expect(subject.say(str)).to be_a
|
860
|
-
end
|
861
|
-
end
|
862
|
-
|
863
|
-
describe "with a default voice set in PB config" do
|
864
|
-
before { Adhearsion.config.punchblock.default_voice = 'foo' }
|
865
|
-
|
866
|
-
it 'sets the voice on the output component' do
|
867
|
-
str = "Hello world"
|
868
|
-
ssml = RubySpeech::SSML.draw { string str }
|
869
|
-
expect_ssml_output ssml, voice: 'foo'
|
870
|
-
subject.say(str)
|
760
|
+
expect(subject.say(str)).to be_a Adhearsion::Rayo::Component::Output
|
871
761
|
end
|
872
|
-
|
873
|
-
after { Adhearsion.config.punchblock.default_voice = nil }
|
874
762
|
end
|
875
763
|
|
876
|
-
describe "with a default voice set in core
|
764
|
+
describe "with a default voice set in core config" do
|
877
765
|
before do
|
878
|
-
Adhearsion.config.
|
879
|
-
Adhearsion.config.platform.media.default_voice = 'bar'
|
766
|
+
Adhearsion.config.core.media.default_voice = 'bar'
|
880
767
|
end
|
881
768
|
|
882
|
-
it '
|
769
|
+
it 'sets the voice on the output component' do
|
883
770
|
str = "Hello world"
|
884
771
|
ssml = RubySpeech::SSML.draw { string str }
|
885
772
|
expect_ssml_output ssml, voice: 'bar'
|
@@ -887,31 +774,16 @@ module Adhearsion
|
|
887
774
|
end
|
888
775
|
|
889
776
|
after do
|
890
|
-
Adhearsion.config.
|
891
|
-
Adhearsion.config.platform.media.default_voice = nil
|
777
|
+
Adhearsion.config.core.media.default_voice = nil
|
892
778
|
end
|
893
779
|
end
|
894
780
|
|
895
|
-
describe "with a default
|
896
|
-
before { Adhearsion.config.punchblock.media_engine = 'foo' }
|
897
|
-
|
898
|
-
it 'sets the renderer on the output component' do
|
899
|
-
str = "Hello world"
|
900
|
-
ssml = RubySpeech::SSML.draw { string str }
|
901
|
-
expect_ssml_output ssml, renderer: 'foo'
|
902
|
-
subject.say(str)
|
903
|
-
end
|
904
|
-
|
905
|
-
after { Adhearsion.config.punchblock.media_engine = nil }
|
906
|
-
end
|
907
|
-
|
908
|
-
describe "with a default renderer set in core and PB config" do
|
781
|
+
describe "with a default renderer set in config" do
|
909
782
|
before do
|
910
|
-
Adhearsion.config.
|
911
|
-
Adhearsion.config.platform.media.default_renderer = 'bar'
|
783
|
+
Adhearsion.config.core.media.default_renderer = 'bar'
|
912
784
|
end
|
913
785
|
|
914
|
-
it '
|
786
|
+
it 'sets the renderer on the output component' do
|
915
787
|
str = "Hello world"
|
916
788
|
ssml = RubySpeech::SSML.draw { string str }
|
917
789
|
expect_ssml_output ssml, renderer: 'bar'
|
@@ -919,8 +791,7 @@ module Adhearsion
|
|
919
791
|
end
|
920
792
|
|
921
793
|
after do
|
922
|
-
Adhearsion.config.
|
923
|
-
Adhearsion.config.platform.media.default_renderer = nil
|
794
|
+
Adhearsion.config.core.media.default_renderer = nil
|
924
795
|
end
|
925
796
|
end
|
926
797
|
|
@@ -929,7 +800,7 @@ module Adhearsion
|
|
929
800
|
argument = 123
|
930
801
|
ssml = RubySpeech::SSML.draw { string '123' }
|
931
802
|
expect_ssml_output ssml
|
932
|
-
expect(subject.say(argument)).to be_a
|
803
|
+
expect(subject.say(argument)).to be_a Adhearsion::Rayo::Component::Output
|
933
804
|
end
|
934
805
|
end
|
935
806
|
end
|
@@ -951,7 +822,7 @@ module Adhearsion
|
|
951
822
|
it 'plays the correct SSML' do
|
952
823
|
ssml = RubySpeech::SSML.draw { string "Hello world" }
|
953
824
|
expect_async_ssml_output ssml
|
954
|
-
expect(subject.say!(ssml)).to be_a
|
825
|
+
expect(subject.say!(ssml)).to be_a Adhearsion::Rayo::Component::Output
|
955
826
|
end
|
956
827
|
end
|
957
828
|
|
@@ -960,30 +831,16 @@ module Adhearsion
|
|
960
831
|
str = "Hello world"
|
961
832
|
ssml = RubySpeech::SSML.draw { string str }
|
962
833
|
expect_async_ssml_output ssml
|
963
|
-
expect(subject.say!(str)).to be_a
|
834
|
+
expect(subject.say!(str)).to be_a Adhearsion::Rayo::Component::Output
|
964
835
|
end
|
965
836
|
end
|
966
837
|
|
967
|
-
describe "with a default voice set in
|
968
|
-
before { Adhearsion.config.punchblock.default_voice = 'foo' }
|
969
|
-
|
970
|
-
it 'sets the voice on the output component' do
|
971
|
-
str = "Hello world"
|
972
|
-
ssml = RubySpeech::SSML.draw { string str }
|
973
|
-
expect_async_ssml_output ssml, voice: 'foo'
|
974
|
-
subject.say!(str)
|
975
|
-
end
|
976
|
-
|
977
|
-
after { Adhearsion.config.punchblock.default_voice = nil }
|
978
|
-
end
|
979
|
-
|
980
|
-
describe "with a default voice set in core and PB config" do
|
838
|
+
describe "with a default voice set in config" do
|
981
839
|
before do
|
982
|
-
Adhearsion.config.
|
983
|
-
Adhearsion.config.platform.media.default_voice = 'bar'
|
840
|
+
Adhearsion.config.core.media.default_voice = 'bar'
|
984
841
|
end
|
985
842
|
|
986
|
-
it '
|
843
|
+
it 'sets the voice on the output component' do
|
987
844
|
str = "Hello world"
|
988
845
|
ssml = RubySpeech::SSML.draw { string str }
|
989
846
|
expect_async_ssml_output ssml, voice: 'bar'
|
@@ -991,31 +848,16 @@ module Adhearsion
|
|
991
848
|
end
|
992
849
|
|
993
850
|
after do
|
994
|
-
Adhearsion.config.
|
995
|
-
Adhearsion.config.platform.media.default_voice = nil
|
996
|
-
end
|
997
|
-
end
|
998
|
-
|
999
|
-
describe "with a default media engine set in PB config" do
|
1000
|
-
before { Adhearsion.config.punchblock.media_engine = 'foo' }
|
1001
|
-
|
1002
|
-
it 'sets the renderer on the output component' do
|
1003
|
-
str = "Hello world"
|
1004
|
-
ssml = RubySpeech::SSML.draw { string str }
|
1005
|
-
expect_async_ssml_output ssml, renderer: 'foo'
|
1006
|
-
subject.say!(str)
|
851
|
+
Adhearsion.config.core.media.default_voice = nil
|
1007
852
|
end
|
1008
|
-
|
1009
|
-
after { Adhearsion.config.punchblock.media_engine = nil }
|
1010
853
|
end
|
1011
854
|
|
1012
|
-
describe "with a default renderer set in
|
855
|
+
describe "with a default renderer set in config" do
|
1013
856
|
before do
|
1014
|
-
Adhearsion.config.
|
1015
|
-
Adhearsion.config.platform.media.default_renderer = 'bar'
|
857
|
+
Adhearsion.config.core.media.default_renderer = 'bar'
|
1016
858
|
end
|
1017
859
|
|
1018
|
-
it '
|
860
|
+
it 'sets the renderer on the output component' do
|
1019
861
|
str = "Hello world"
|
1020
862
|
ssml = RubySpeech::SSML.draw { string str }
|
1021
863
|
expect_async_ssml_output ssml, renderer: 'bar'
|
@@ -1023,8 +865,7 @@ module Adhearsion
|
|
1023
865
|
end
|
1024
866
|
|
1025
867
|
after do
|
1026
|
-
Adhearsion.config.
|
1027
|
-
Adhearsion.config.platform.media.default_renderer = nil
|
868
|
+
Adhearsion.config.core.media.default_renderer = nil
|
1028
869
|
end
|
1029
870
|
end
|
1030
871
|
|
@@ -1033,7 +874,7 @@ module Adhearsion
|
|
1033
874
|
argument = 123
|
1034
875
|
ssml = RubySpeech::SSML.draw { string '123' }
|
1035
876
|
expect_async_ssml_output ssml
|
1036
|
-
expect(subject.say!(argument)).to be_a
|
877
|
+
expect(subject.say!(argument)).to be_a Adhearsion::Rayo::Component::Output
|
1037
878
|
end
|
1038
879
|
end
|
1039
880
|
end
|
@@ -1082,7 +923,7 @@ module Adhearsion
|
|
1082
923
|
|
1083
924
|
it 'plays the correct ssml' do
|
1084
925
|
expect_async_ssml_output ssml
|
1085
|
-
expect(subject.say_characters!('1234#abc')).to be_a
|
926
|
+
expect(subject.say_characters!('1234#abc')).to be_a Adhearsion::Rayo::Component::Output
|
1086
927
|
end
|
1087
928
|
end
|
1088
929
|
|
@@ -1095,7 +936,113 @@ module Adhearsion
|
|
1095
936
|
|
1096
937
|
it 'plays the correct ssml' do
|
1097
938
|
expect_async_ssml_output ssml
|
1098
|
-
expect(subject.say_characters!(1234)).to be_a
|
939
|
+
expect(subject.say_characters!(1234)).to be_a Adhearsion::Rayo::Component::Output
|
940
|
+
end
|
941
|
+
end
|
942
|
+
end
|
943
|
+
|
944
|
+
describe "i18n" do
|
945
|
+
before do
|
946
|
+
I18n.default_locale = :en
|
947
|
+
end
|
948
|
+
|
949
|
+
describe 'getting and setting the locale' do
|
950
|
+
it 'should be able to set and get the locale' do
|
951
|
+
expect(controller.locale).to be(:en)
|
952
|
+
controller.locale = :it
|
953
|
+
expect(controller.locale).to be(:it)
|
954
|
+
end
|
955
|
+
end
|
956
|
+
|
957
|
+
describe 'requesting a translation' do
|
958
|
+
it 'should use a default locale' do
|
959
|
+
ssml = controller.t :have_many_cats
|
960
|
+
expect(ssml['xml:lang']).to match(/^en/)
|
961
|
+
end
|
962
|
+
|
963
|
+
it 'should allow overriding the locale per-request' do
|
964
|
+
ssml = controller.t :have_many_cats, locale: 'it'
|
965
|
+
expect(ssml['xml:lang']).to match(/^it/)
|
966
|
+
end
|
967
|
+
|
968
|
+
it 'should allow overriding the locale for the entire call' do
|
969
|
+
controller.locale = 'it'
|
970
|
+
ssml = controller.t :have_many_cats
|
971
|
+
expect(ssml['xml:lang']).to match(/^it/)
|
972
|
+
controller2 = Class.new(Adhearsion::CallController).new call
|
973
|
+
expect(controller2.locale).to eql('it')
|
974
|
+
end
|
975
|
+
|
976
|
+
it 'should generate proper SSML with both audio and text fallback translations' do
|
977
|
+
ssml = controller.t :have_many_cats
|
978
|
+
expect(ssml).to eql(RubySpeech::SSML.draw(language: 'en') do
|
979
|
+
audio src: "file://#{Adhearsion.root}/app/assets/audio/en/have_many_cats.wav" do
|
980
|
+
string 'I have quite a few cats'
|
981
|
+
end
|
982
|
+
end)
|
983
|
+
end
|
984
|
+
|
985
|
+
it 'should generate proper SSML with only audio (no fallback text) translations' do
|
986
|
+
ssml = controller.t :my_shirt_is_white
|
987
|
+
expect(ssml).to eql(RubySpeech::SSML.draw(language: 'en') do
|
988
|
+
audio src: "file://#{Adhearsion.root}/app/assets/audio/en/my_shirt_is_white.wav" do
|
989
|
+
string ''
|
990
|
+
end
|
991
|
+
end)
|
992
|
+
end
|
993
|
+
|
994
|
+
it 'should generate proper SSML with only text (no audio) translations' do
|
995
|
+
ssml = controller.t :many_people_out_today
|
996
|
+
expect(ssml).to eql(RubySpeech::SSML.draw(language: 'en') do
|
997
|
+
string 'There are many people out today'
|
998
|
+
end)
|
999
|
+
end
|
1000
|
+
|
1001
|
+
it 'should generate a path to the audio prompt based on the requested locale' do
|
1002
|
+
ssml = controller.t :my_shirt_is_white, locale: 'it'
|
1003
|
+
expect(ssml).to eql(RubySpeech::SSML.draw(language: 'it') do
|
1004
|
+
audio src: "file://#{Adhearsion.root}/app/assets/audio/it/la_mia_camicia_e_bianca.wav" do
|
1005
|
+
string ''
|
1006
|
+
end
|
1007
|
+
end)
|
1008
|
+
end
|
1009
|
+
|
1010
|
+
it 'should fall back to a text translation if the locale structure does not break out audio vs. tts' do
|
1011
|
+
ssml = controller.t :seventeen, locale: 'it'
|
1012
|
+
expect(ssml).to eql(RubySpeech::SSML.draw(language: 'it') do
|
1013
|
+
string 'diciassette'
|
1014
|
+
end)
|
1015
|
+
end
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
describe 'with fallback disabled, requesting a translation' do
|
1019
|
+
before do
|
1020
|
+
Adhearsion.config.core.i18n.fallback = false
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
after do
|
1024
|
+
Adhearsion.config.core.i18n.fallback = true
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
it 'should generate proper SSML with only audio (no text) translations' do
|
1028
|
+
ssml = controller.t :my_shirt_is_white
|
1029
|
+
expect(ssml).to eql(RubySpeech::SSML.draw(language: 'en') do
|
1030
|
+
audio src: "file://#{Adhearsion.root}/app/assets/audio/en/my_shirt_is_white.wav"
|
1031
|
+
end)
|
1032
|
+
end
|
1033
|
+
|
1034
|
+
it 'should generate proper SSML with only text (no audio) translations' do
|
1035
|
+
ssml = controller.t :many_people_out_today
|
1036
|
+
expect(ssml).to eql(RubySpeech::SSML.draw(language: 'en') do
|
1037
|
+
string 'There are many people out today'
|
1038
|
+
end)
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
it 'should generate proper SSML with only audio translations when both are supplied' do
|
1042
|
+
ssml = controller.t :have_many_cats
|
1043
|
+
expect(ssml).to eql(RubySpeech::SSML.draw(language: 'en') do
|
1044
|
+
audio src: "file://#{Adhearsion.root}/app/assets/audio/en/have_many_cats.wav"
|
1045
|
+
end)
|
1099
1046
|
end
|
1100
1047
|
end
|
1101
1048
|
end
|