Permalink
Browse files

Merge branch 'refs/heads/develop' into feature/prompt_interrupt

  • Loading branch information...
2 parents da7370e + bb79ffc commit fb433eb3a93092bd5995166381372d93edd6a348 @benlangfeld benlangfeld committed Nov 15, 2012
Showing with 21 additions and 2 deletions.
  1. +2 −1 lib/adhearsion-asr/controller_methods.rb
  2. +19 −1 spec/adhearsion-asr/controller_methods_spec.rb
@@ -34,8 +34,9 @@ def listen(opts = {})
grammar_opts = if opts[:grammar_url]
{ url: opts[:grammar_url] }
else
+ language = opts.delete(:language) || 'en-us'
grammar = opts[:grammar]
- grammar ||= RubySpeech::GRXML.draw root: 'main' do
+ grammar ||= RubySpeech::GRXML.draw root: 'main', language: language do
rule id: 'main', scope: 'public' do
one_of do
opts[:options].each do |option|
@@ -45,7 +45,7 @@ def expect_component_execution(component, fail = false)
describe "#listen" do
let(:grxml) {
- RubySpeech::GRXML.draw :root => 'main' do
+ RubySpeech::GRXML.draw :root => 'main', :language => 'en-us' do
rule id: 'main', scope: 'public' do
one_of do
item { 'yes' }
@@ -94,6 +94,24 @@ def expect_component_complete_event
subject.listen grammar_url: url
end
+ it "should default the recognition language to 'en-us'" do
+ expect_component_complete_event
+ controller.should_receive(:execute_component_and_await_completion).once.ordered do |component|
+ grammar = component.grammar.value
+ grammar['lang'].should == 'en-us'
+ end
+ subject.listen options: %w{yes no}
+ end
+
+ it "allows specifying a recognition language" do
+ expect_component_complete_event
+ controller.should_receive(:execute_component_and_await_completion).once.ordered do |component|
+ grammar = component.grammar.value
+ grammar['lang'].should == 'en-gb'
+ end
+ subject.listen options: %w{yes no}, language: 'en-gb'
+ end
+
it "raises ArgumentError when not provided options, a grammar or a grammar URL" do
expect { subject.listen }.to raise_error(ArgumentError, "You must provide a grammar, a grammar URL or a set of options")
end

0 comments on commit fb433eb

Please sign in to comment.