From c7bb59a22af7c596cb6c2861eaca8fb161997599 Mon Sep 17 00:00:00 2001 From: Luca Pradovera Date: Tue, 14 Mar 2017 11:35:54 +0100 Subject: [PATCH] First pass at specs --- spec/ruby_speech/grxml/matcher_spec.rb | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/spec/ruby_speech/grxml/matcher_spec.rb b/spec/ruby_speech/grxml/matcher_spec.rb index aaa5cb6..b20cfa8 100644 --- a/spec/ruby_speech/grxml/matcher_spec.rb +++ b/spec/ruby_speech/grxml/matcher_spec.rb @@ -227,6 +227,41 @@ module GRXML end end + context "with a grammar that takes a double digit and a single digit that is a partial match" do + let(:grammar) do + GRXML.draw :mode => :dtmf, :root => 'digits' do + rule :id => 'digits' do + one_of do + item { '6' } + item { '6 7' } + end + end + end + end + + it "should maximally match '6 7'" do + expected_match = GRXML::MaxMatch.new :mode => :dtmf, + :confidence => 1, + :utterance => '67', + :interpretation => 'dtmf-6 dtmf-7' + subject.match('67').should == expected_match + end + + it "should match '6'" do + expected_match = GRXML::Match.new :mode => :dtmf, + :confidence => 1, + :utterance => '6', + :interpretation => 'dtmf-6' + subject.match('6').should == expected_match + end + + %w{* # 1 2 3 4 5 8 9 10 66 26 61}.each do |input| + it "should not match '#{input}'" do + subject.match(input).should == GRXML::NoMatch.new + end + end + end + context "with a grammar that takes a double digit alternative" do let(:grammar) do GRXML.draw :mode => :dtmf, :root => 'digits' do