Skip to content

Commit

Permalink
Add specs covering #30
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed May 23, 2014
1 parent 960b163 commit a3a837c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions spec/ruby_speech/grxml/matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,50 @@ module GRXML
end
end

context "with a grammar that takes a a specific digit repeated within a range" do
let(:grammar) do
GRXML.draw :mode => :dtmf, :root => 'digits' do
rule :id => 'digits' do
item :repeat => 0..3 do
'6'
end
end
end
end

{
'' => '',
'6' => 'dtmf-6',
'66' => 'dtmf-6 dtmf-6',
}.each_pair do |input, interpretation|
it "should match '#{input}'" do
expected_match = GRXML::Match.new :mode => :dtmf,
:confidence => 1,
:utterance => input,
:interpretation => interpretation
subject.match(input).should == expected_match
end
end

{
'666' => 'dtmf-6 dtmf-6 dtmf-6',
}.each_pair do |input, interpretation|
it "should maximally match '#{input}'" do
expected_match = GRXML::MaxMatch.new :mode => :dtmf,
:confidence => 1,
:utterance => input,
:interpretation => interpretation
subject.match(input).should == expected_match
end
end

%w{6666 7}.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 a specific digit repeated within a range, followed by specific digit" do
let(:grammar) do
GRXML.draw :mode => :dtmf, :root => 'digits' do
Expand Down

0 comments on commit a3a837c

Please sign in to comment.