spec/punchblock/component/input_spec.rb in punchblock-2.5.3 vs spec/punchblock/component/input_spec.rb in punchblock-2.6.0

- old
+ new

@@ -17,12 +17,14 @@ :max_silence => 1000, :recognizer => 'default', :language => 'en-US', :initial_timeout => 2000, :inter_digit_timeout => 2000, + :recognition_timeout => 0, :sensitivity => 0.5, - :min_confidence => 0.5 + :min_confidence => 0.5, + :headers => { 'Confidence-Threshold' => '0.5', 'Sensitivity-Level' => '0.2' } end describe '#grammars' do subject { super().grammars } it { should be == [Input::Grammar.new(:value => '[5 DIGITS]', :content_type => 'application/grammar+custom')] } @@ -61,10 +63,15 @@ describe '#inter_digit_timeout' do subject { super().inter_digit_timeout } it { should be == 2000 } end + describe '#recognition_timeout' do + subject { super().recognition_timeout } + it { should be == 0 } + end + describe '#sensitivity' do subject { super().sensitivity } it { should be == 0.5 } end @@ -104,10 +111,15 @@ subject { super().grammars } it { should == [] } end end + describe '#headers' do + subject { super().headers } + it { should be == { 'Confidence-Threshold' => '0.5', 'Sensitivity-Level' => '0.2' } } + end + describe "exporting to Rayo" do it "should export to XML that can be understood by its parser" do new_instance = RayoNode.from_xml subject.to_rayo expect(new_instance).to be_instance_of described_class expect(new_instance.grammars).to eq([Input::Grammar.new(value: '[5 DIGITS]', content_type: 'application/grammar+custom')]) @@ -116,12 +128,14 @@ expect(new_instance.max_silence).to eq(1000) expect(new_instance.recognizer).to eq('default') expect(new_instance.language).to eq('en-US') expect(new_instance.initial_timeout).to eq(2000) expect(new_instance.inter_digit_timeout).to eq(2000) + expect(new_instance.recognition_timeout).to eq(0) expect(new_instance.sensitivity).to eq(0.5) expect(new_instance.min_confidence).to eq(0.5) + expect(new_instance.headers).to eq({ 'Confidence-Threshold' => '0.5', 'Sensitivity-Level' => '0.2' }) end it "should wrap the grammar value in CDATA" do grammar_node = subject.to_rayo.at_xpath('ns:grammar', ns: described_class.registered_ns) expect(grammar_node.children.first).to be_a Nokogiri::XML::CDATA @@ -146,18 +160,21 @@ max-silence="1000" recognizer="default" language="en-US" initial-timeout="2000" inter-digit-timeout="2000" + recognition-timeout="0" sensitivity="0.5" min-confidence="0.5"> <grammar content-type="application/grammar+custom"> <![CDATA[ [5 DIGITS] ]]> </grammar> <grammar content-type="application/grammar+custom"> <![CDATA[ [10 DIGITS] ]]> </grammar> + <header xmlns='urn:xmpp:rayo:1' name="Confidence-Threshold" value="0.5" /> + <header xmlns='urn:xmpp:rayo:1' name="Sensitivity-Level" value="0.2" /> </input> MESSAGE end subject { RayoNode.from_xml parse_stanza(stanza).root, '9f00061', '1' } @@ -202,10 +219,15 @@ describe '#inter_digit_timeout' do subject { super().inter_digit_timeout } it { should be == 2000 } end + describe '#recognition_timeout' do + subject { super().recognition_timeout } + it { should be == 0 } + end + describe '#sensitivity' do subject { super().sensitivity } it { should be == 0.5 } end @@ -219,9 +241,14 @@ describe '#grammars' do subject { super().grammars } it { should be == [] } end + end + + describe '#headers' do + subject { super().headers } + it { should be == { 'Confidence-Threshold' => '0.5', 'Sensitivity-Level' => '0.2' } } end end def grxml_doc(mode = :dtmf) RubySpeech::GRXML.draw :mode => mode.to_s, :root => 'digits' do