ruby_speech 2.3.1-java → 3.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.hound.yml +2 -0
  4. data/.travis.yml +25 -9
  5. data/CHANGELOG.md +19 -1
  6. data/README.md +14 -15
  7. data/Rakefile +2 -0
  8. data/ext/ruby_speech/RubySpeechGRXMLMatcher.java +17 -12
  9. data/ext/ruby_speech/RubySpeechService.java +1 -1
  10. data/ext/ruby_speech/extconf.rb +1 -1
  11. data/lib/ruby_speech/generic_element.rb +2 -2
  12. data/lib/ruby_speech/grxml/builtins.rb +18 -11
  13. data/lib/ruby_speech/grxml/grammar.rb +26 -4
  14. data/lib/ruby_speech/grxml/matcher.rb +2 -2
  15. data/lib/ruby_speech/grxml.rb +2 -0
  16. data/lib/ruby_speech/nlsml/builder.rb +2 -1
  17. data/lib/ruby_speech/nlsml/document.rb +5 -0
  18. data/lib/ruby_speech/ruby_speech.jar +0 -0
  19. data/lib/ruby_speech/ssml/break.rb +1 -2
  20. data/lib/ruby_speech/ssml/element.rb +13 -1
  21. data/lib/ruby_speech/ssml/mark.rb +0 -1
  22. data/lib/ruby_speech/ssml/prosody.rb +8 -5
  23. data/lib/ruby_speech/version.rb +1 -1
  24. data/ruby_speech.gemspec +13 -8
  25. data/spec/ruby_speech/grxml/builtins_spec.rb +80 -71
  26. data/spec/ruby_speech/grxml/grammar_spec.rb +168 -34
  27. data/spec/ruby_speech/grxml/item_spec.rb +33 -33
  28. data/spec/ruby_speech/grxml/match_spec.rb +1 -1
  29. data/spec/ruby_speech/grxml/matcher_spec.rb +103 -59
  30. data/spec/ruby_speech/grxml/max_match_spec.rb +2 -2
  31. data/spec/ruby_speech/grxml/no_match_spec.rb +2 -2
  32. data/spec/ruby_speech/grxml/one_of_spec.rb +6 -6
  33. data/spec/ruby_speech/grxml/potential_match_spec.rb +2 -2
  34. data/spec/ruby_speech/grxml/rule_spec.rb +17 -17
  35. data/spec/ruby_speech/grxml/ruleref_spec.rb +10 -10
  36. data/spec/ruby_speech/grxml/tag_spec.rb +5 -5
  37. data/spec/ruby_speech/grxml/token_spec.rb +7 -7
  38. data/spec/ruby_speech/grxml_spec.rb +25 -25
  39. data/spec/ruby_speech/nlsml_spec.rb +58 -10
  40. data/spec/ruby_speech/ssml/audio_spec.rb +19 -19
  41. data/spec/ruby_speech/ssml/break_spec.rb +42 -22
  42. data/spec/ruby_speech/ssml/desc_spec.rb +7 -7
  43. data/spec/ruby_speech/ssml/emphasis_spec.rb +21 -21
  44. data/spec/ruby_speech/ssml/mark_spec.rb +5 -5
  45. data/spec/ruby_speech/ssml/p_spec.rb +17 -17
  46. data/spec/ruby_speech/ssml/phoneme_spec.rb +8 -8
  47. data/spec/ruby_speech/ssml/prosody_spec.rb +82 -64
  48. data/spec/ruby_speech/ssml/s_spec.rb +16 -16
  49. data/spec/ruby_speech/ssml/say_as_spec.rb +9 -9
  50. data/spec/ruby_speech/ssml/speak_spec.rb +29 -29
  51. data/spec/ruby_speech/ssml/sub_spec.rb +7 -7
  52. data/spec/ruby_speech/ssml/voice_spec.rb +31 -31
  53. data/spec/ruby_speech/ssml_spec.rb +41 -17
  54. data/spec/ruby_speech_spec.rb +3 -3
  55. data/spec/spec_helper.rb +8 -3
  56. data/spec/support/dtmf_helper.rb +14 -0
  57. data/spec/support/grammar_matchers.rb +6 -6
  58. data/spec/support/match_examples.rb +5 -5
  59. data/spec/support/matchers.rb +1 -1
  60. metadata +109 -80
@@ -10,7 +10,7 @@ module RubySpeech
10
10
  its(:name) { should == 'one-of' }
11
11
 
12
12
  it 'registers itself' do
13
- Element.class_from_registration(:'one-of').should == OneOf
13
+ expect(Element.class_from_registration(:'one-of')).to eq(OneOf)
14
14
  end
15
15
 
16
16
  describe "from a document" do
@@ -18,7 +18,7 @@ module RubySpeech
18
18
 
19
19
  subject { Element.import document }
20
20
 
21
- it { should be_instance_of OneOf }
21
+ it { is_expected.to be_instance_of OneOf }
22
22
  end
23
23
 
24
24
  describe "#language" do
@@ -29,22 +29,22 @@ module RubySpeech
29
29
 
30
30
  describe "<<" do
31
31
  it "should accept Item" do
32
- lambda { subject << Item.new(doc) }.should_not raise_error
32
+ expect { subject << Item.new(doc) }.not_to raise_error
33
33
  end
34
34
 
35
35
  it "should raise InvalidChildError with non-acceptable objects" do
36
- lambda { subject << 1 }.should raise_error(InvalidChildError, "A OneOf can only accept Item as children")
36
+ expect { subject << 1 }.to raise_error(InvalidChildError, "A OneOf can only accept Item as children")
37
37
  end
38
38
  end
39
39
 
40
40
  describe "comparing objects" do
41
41
  it "should be equal if the language (when specified) is the same" do
42
- OneOf.new(doc, :language => "jp").should == OneOf.new(doc, :language => "jp")
42
+ expect(OneOf.new(doc, :language => "jp")).to eq(OneOf.new(doc, :language => "jp"))
43
43
  end
44
44
 
45
45
  describe "when the language is different" do
46
46
  it "should not be equal" do
47
- OneOf.new(doc, :language => "jp").should_not == OneOf.new(doc, :content => "fr-CA")
47
+ expect(OneOf.new(doc, :language => "jp")).not_to eq(OneOf.new(doc, :content => "fr-CA"))
48
48
  end
49
49
  end
50
50
  end
@@ -5,11 +5,11 @@ module RubySpeech
5
5
  describe PotentialMatch do
6
6
  describe "equality" do
7
7
  it "should be equal to another PotentialMatch" do
8
- PotentialMatch.new.should == PotentialMatch.new
8
+ expect(PotentialMatch.new).to eq(PotentialMatch.new)
9
9
  end
10
10
 
11
11
  it "should not equal a match" do
12
- PotentialMatch.new.should_not == Match.new
12
+ expect(PotentialMatch.new).not_to eq(Match.new)
13
13
  end
14
14
  end
15
15
  end
@@ -13,7 +13,7 @@ module RubySpeech
13
13
  its(:scope) { should == :public }
14
14
 
15
15
  it 'registers itself' do
16
- Element.class_from_registration(:rule).should == Rule
16
+ expect(Element.class_from_registration(:rule)).to eq(Rule)
17
17
  end
18
18
 
19
19
  describe "from a document" do
@@ -21,7 +21,7 @@ module RubySpeech
21
21
 
22
22
  subject { Element.import document }
23
23
 
24
- it { should be_instance_of Rule }
24
+ it { is_expected.to be_instance_of Rule }
25
25
 
26
26
  its(:id) { should == :one }
27
27
  its(:scope) { should == :public }
@@ -54,73 +54,73 @@ module RubySpeech
54
54
  its(:scope) { should == :public }
55
55
 
56
56
  it "with a valid scope" do
57
- lambda { subject.scope = :public }.should_not raise_error
58
- lambda { subject.scope = :private }.should_not raise_error
57
+ expect { subject.scope = :public }.not_to raise_error
58
+ expect { subject.scope = :private }.not_to raise_error
59
59
  end
60
60
 
61
61
  it "with an invalid scope" do
62
- lambda { subject.scope = :something }.should raise_error(ArgumentError, "A Rule's scope can only be 'public' or 'private'")
62
+ expect { subject.scope = :something }.to raise_error(ArgumentError, "A Rule's scope can only be 'public' or 'private'")
63
63
  end
64
64
  end
65
65
 
66
66
  describe "comparing objects" do
67
67
  it "should be equal if the content, language, id, and scope are the same" do
68
- Rule.new(doc, :language => 'jp', :id => :main, :scope => :public, :content => "hello").should == Rule.new(doc, :language => 'jp', :id => :main, :scope => :public, :content => "hello")
68
+ expect(Rule.new(doc, :language => 'jp', :id => :main, :scope => :public, :content => "hello")).to eq(Rule.new(doc, :language => 'jp', :id => :main, :scope => :public, :content => "hello"))
69
69
  end
70
70
 
71
71
  describe "when the content is different" do
72
72
  it "should not be equal" do
73
- Rule.new(doc, :content => "Hello").should_not == Rule.new(doc, :content => "Hello there")
73
+ expect(Rule.new(doc, :content => "Hello")).not_to eq(Rule.new(doc, :content => "Hello there"))
74
74
  end
75
75
  end
76
76
 
77
77
  describe "when the language is different" do
78
78
  it "should not be equal" do
79
- Rule.new(doc, :language => "jp").should_not == Rule.new(doc, :language => "esperanto")
79
+ expect(Rule.new(doc, :language => "jp")).not_to eq(Rule.new(doc, :language => "esperanto"))
80
80
  end
81
81
  end
82
82
 
83
83
  describe "when the id is different" do
84
84
  it "should not be equal" do
85
- Rule.new(doc, :id => :main).should_not == Rule.new(doc, :id => :dtmf)
85
+ expect(Rule.new(doc, :id => :main)).not_to eq(Rule.new(doc, :id => :dtmf))
86
86
  end
87
87
  end
88
88
 
89
89
  describe "when the scope is different" do
90
90
  it "should not be equal" do
91
- Rule.new(doc, :scope => :public).should_not == Rule.new(doc, :scope => :private)
91
+ expect(Rule.new(doc, :scope => :public)).not_to eq(Rule.new(doc, :scope => :private))
92
92
  end
93
93
  end
94
94
  end
95
95
 
96
96
  describe "<<" do
97
97
  it "should accept String" do
98
- lambda { subject << 'anything' }.should_not raise_error
98
+ expect { subject << 'anything' }.not_to raise_error
99
99
  end
100
100
 
101
101
  it "should accept OneOf" do
102
- lambda { subject << OneOf.new(doc) }.should_not raise_error
102
+ expect { subject << OneOf.new(doc) }.not_to raise_error
103
103
  end
104
104
 
105
105
  it "should accept Item" do
106
- lambda { subject << Item.new(doc) }.should_not raise_error
106
+ expect { subject << Item.new(doc) }.not_to raise_error
107
107
  end
108
108
 
109
109
  it "should accept Ruleref" do
110
- lambda { subject << Ruleref.new(doc) }.should_not raise_error
110
+ expect { subject << Ruleref.new(doc) }.not_to raise_error
111
111
  end
112
112
 
113
113
  it "should accept Tag" do
114
- lambda { subject << Tag.new(doc) }.should_not raise_error
114
+ expect { subject << Tag.new(doc) }.not_to raise_error
115
115
  end
116
116
 
117
117
  it "should accept Token" do
118
- lambda { subject << Token.new(doc) }.should_not raise_error
118
+ expect { subject << Token.new(doc) }.not_to raise_error
119
119
  end
120
120
  end
121
121
 
122
122
  it "should raise ArgumentError with any other scope" do
123
- lambda { Rule.new doc, :id => 'one', :scope => 'invalid_scope' }.should raise_error(ArgumentError, "A Rule's scope can only be 'public' or 'private'")
123
+ expect { Rule.new doc, :id => 'one', :scope => 'invalid_scope' }.to raise_error(ArgumentError, "A Rule's scope can only be 'public' or 'private'")
124
124
  end
125
125
  end # Rule
126
126
  end # GRXML
@@ -11,7 +11,7 @@ module RubySpeech
11
11
  its(:uri) { should == '#testrule' }
12
12
 
13
13
  it 'registers itself' do
14
- Element.class_from_registration(:ruleref).should == Ruleref
14
+ expect(Element.class_from_registration(:ruleref)).to eq(Ruleref)
15
15
  end
16
16
 
17
17
  describe "from a document" do
@@ -19,7 +19,7 @@ module RubySpeech
19
19
 
20
20
  subject { Element.import document }
21
21
 
22
- it { should be_instance_of Ruleref }
22
+ it { is_expected.to be_instance_of Ruleref }
23
23
 
24
24
  its(:uri) { should == '#one' }
25
25
  end
@@ -29,27 +29,27 @@ module RubySpeech
29
29
 
30
30
  context "with reserved values" do
31
31
  it "with a valid value" do
32
- lambda { subject.special = :NULL }.should_not raise_error
33
- lambda { subject.special = :VOID }.should_not raise_error
34
- lambda { subject.special = 'GARBAGE' }.should_not raise_error
32
+ expect { subject.special = :NULL }.not_to raise_error
33
+ expect { subject.special = :VOID }.not_to raise_error
34
+ expect { subject.special = 'GARBAGE' }.not_to raise_error
35
35
  end
36
36
  it "with an invalid value" do
37
- lambda { subject.special = :SOMETHINGELSE }.should raise_error
37
+ expect { subject.special = :SOMETHINGELSE }.to raise_error
38
38
  end
39
39
  end
40
40
  end
41
41
 
42
42
  describe "#uri" do
43
43
  it "allows implict, explicit and external references" do
44
- lambda { subject.uri = '#dtmf' }.should_not raise_error
45
- lambda { subject.uri = '../test.grxml' }.should_not raise_error
46
- lambda { subject.uri = 'http://grammar.example.com/world-cities.grxml#canada' }.should_not raise_error
44
+ expect { subject.uri = '#dtmf' }.not_to raise_error
45
+ expect { subject.uri = '../test.grxml' }.not_to raise_error
46
+ expect { subject.uri = 'http://grammar.example.com/world-cities.grxml#canada' }.not_to raise_error
47
47
  end
48
48
  end
49
49
 
50
50
  describe "only uri or special can be specified" do
51
51
  it "should raise an error" do
52
- lambda { subject << Ruleref.new(doc, :uri => '#test', :special => :NULL) }.should raise_error(ArgumentError, "A Ruleref can only take uri or special")
52
+ expect { subject << Ruleref.new(doc, :uri => '#test', :special => :NULL) }.to raise_error(ArgumentError, "A Ruleref can only take uri or special")
53
53
  end
54
54
  end
55
55
  end # Ruleref
@@ -10,7 +10,7 @@ module RubySpeech
10
10
  its(:name) { should == 'tag' }
11
11
 
12
12
  it 'registers itself' do
13
- Element.class_from_registration(:tag).should == Tag
13
+ expect(Element.class_from_registration(:tag)).to eq(Tag)
14
14
  end
15
15
 
16
16
  describe "from a document" do
@@ -18,26 +18,26 @@ module RubySpeech
18
18
 
19
19
  subject { Element.import document }
20
20
 
21
- it { should be_instance_of Tag }
21
+ it { is_expected.to be_instance_of Tag }
22
22
 
23
23
  its(:content) { should == 'hello' }
24
24
  end
25
25
 
26
26
  describe "comparing objects" do
27
27
  it "should be equal if the content is the same" do
28
- Tag.new(doc, :content => "hello").should == Tag.new(doc, :content => "hello")
28
+ expect(Tag.new(doc, :content => "hello")).to eq(Tag.new(doc, :content => "hello"))
29
29
  end
30
30
 
31
31
  describe "when the content is different" do
32
32
  it "should not be equal" do
33
- Tag.new(doc, :content => "Hello").should_not == Tag.new(doc, :content => "Hello there")
33
+ expect(Tag.new(doc, :content => "Hello")).not_to eq(Tag.new(doc, :content => "Hello there"))
34
34
  end
35
35
  end
36
36
  end
37
37
 
38
38
  describe "<<" do
39
39
  it "should accept String" do
40
- lambda { subject << 'anything' }.should_not raise_error
40
+ expect { subject << 'anything' }.not_to raise_error
41
41
  end
42
42
  end
43
43
  end # Tag
@@ -10,7 +10,7 @@ module RubySpeech
10
10
  its(:name) { should == 'token' }
11
11
 
12
12
  it 'registers itself' do
13
- Element.class_from_registration(:token).should == Token
13
+ expect(Element.class_from_registration(:token)).to eq(Token)
14
14
  end
15
15
 
16
16
  describe "from a document" do
@@ -18,7 +18,7 @@ module RubySpeech
18
18
 
19
19
  subject { Element.import document }
20
20
 
21
- it { should be_instance_of Token }
21
+ it { is_expected.to be_instance_of Token }
22
22
 
23
23
  its(:content) { should == 'hello' }
24
24
  end
@@ -35,30 +35,30 @@ module RubySpeech
35
35
 
36
36
  element.normalize_whitespace
37
37
 
38
- element.content.should == 'Welcome to San Francisco'
38
+ expect(element.content).to eq('Welcome to San Francisco')
39
39
  end
40
40
  end
41
41
 
42
42
  describe "comparing objects" do
43
43
  it "should be equal if the content is the same" do
44
- Token.new(doc, :content => "hello").should == Token.new(doc, :content => "hello")
44
+ expect(Token.new(doc, :content => "hello")).to eq(Token.new(doc, :content => "hello"))
45
45
  end
46
46
 
47
47
  describe "when the content is different" do
48
48
  it "should not be equal" do
49
- Token.new(doc, :content => "Hello").should_not == Token.new(doc, :content => "Hello there")
49
+ expect(Token.new(doc, :content => "Hello")).not_to eq(Token.new(doc, :content => "Hello there"))
50
50
  end
51
51
  end
52
52
  end
53
53
 
54
54
  describe "<<" do
55
55
  it "should accept String" do
56
- lambda { subject << 'anything' }.should_not raise_error
56
+ expect { subject << 'anything' }.not_to raise_error
57
57
  end
58
58
 
59
59
  it "should allow chaining" do
60
60
  subject << 'foo' << 'bar'
61
- subject.content.should == 'foobar'
61
+ expect(subject.content).to eq('foobar')
62
62
  end
63
63
  end
64
64
  end # Token
@@ -5,11 +5,11 @@ module RubySpeech
5
5
  describe ".from_uri" do
6
6
  context "with a builtin URI" do
7
7
  it "should fetch a simple builtin grammar by type" do
8
- subject.from_uri("builtin:dtmf/phone").should == GRXML::Builtins.phone
8
+ expect(subject.from_uri("builtin:dtmf/phone")).to eq(GRXML::Builtins.phone)
9
9
  end
10
10
 
11
11
  it "should fetch a parameterized builtin grammar" do
12
- subject.from_uri("builtin:dtmf/boolean?y=3;n=4").should == GRXML::Builtins.boolean(y: 3, n: 4)
12
+ expect(subject.from_uri("builtin:dtmf/boolean?y=3;n=4")).to eq(GRXML::Builtins.boolean(y: 3, n: 4))
13
13
  end
14
14
 
15
15
  context "for speech" do
@@ -36,26 +36,26 @@ module RubySpeech
36
36
  let(:doc) { Nokogiri::XML::Document.new }
37
37
 
38
38
  it "should create a GRXML document" do
39
- GRXML.draw.should == GRXML::Grammar.new(doc)
40
- GRXML.draw.document.xpath('ns:grammar', ns: 'http://www.w3.org/2001/06/grammar').size.should == 1
39
+ expect(GRXML.draw).to eq(GRXML::Grammar.new(doc))
40
+ expect(GRXML.draw.document.xpath('ns:grammar', ns: 'http://www.w3.org/2001/06/grammar').size).to eq(1)
41
41
  end
42
42
 
43
43
  context "with a root rule name specified but not found" do
44
44
  it "should raise an error" do
45
- lambda do
45
+ expect do
46
46
  GRXML.draw :root => 'foo' do
47
47
  rule :id => 'bar' do
48
48
  '6'
49
49
  end
50
50
  end
51
- end.should raise_error(GRXML::InvalidChildError, "A GRXML document must have a rule matching the root rule name")
51
+ end.to raise_error(GRXML::InvalidChildError, "A GRXML document must have a rule matching the root rule name")
52
52
  end
53
53
  end
54
54
 
55
55
  # TODO: Maybe GRXML#draw should create a Rule to pass the string
56
56
  describe "when the return value of the block is a string" do
57
57
  it "should be inserted into the document" do
58
- lambda { GRXML.draw { "Hello Fred" }}.should raise_error(GRXML::InvalidChildError, "A Grammar can only accept Rule and Tag as children")
58
+ expect { GRXML.draw { "Hello Fred" }}.to raise_error(GRXML::InvalidChildError, "A Grammar can only accept Rule and Tag as children")
59
59
  end
60
60
  end
61
61
 
@@ -66,7 +66,7 @@ module RubySpeech
66
66
  rule = GRXML::Rule.new(doc, :id => "main")
67
67
  rule << "Hello Fred"
68
68
  expected_doc << rule
69
- drawn_doc.should == expected_doc
69
+ expect(drawn_doc).to eq(expected_doc)
70
70
  end
71
71
 
72
72
  it "should allow accessing methods defined outside the block" do
@@ -81,12 +81,12 @@ module RubySpeech
81
81
  expected_doc = GRXML::Grammar.new doc
82
82
  rule = GRXML::Rule.new(doc, :id => foo)
83
83
  expected_doc << rule
84
- drawn_doc.should == expected_doc
84
+ expect(drawn_doc).to eq(expected_doc)
85
85
  end
86
86
 
87
87
  it "should raise error if given an empty rule" do
88
88
  pending 'Reject empty rules -- http://www.w3.org/TR/2002/CR-speech-grammar-20020626/#S3.1 http://www.w3.org/Voice/2003/srgs-ir/test/rule-no-empty.grxml'
89
- lambda { GRXML.draw { rule :id => 'main' }}.should raise_error
89
+ expect { GRXML.draw { rule :id => 'main' }}.to raise_error
90
90
  end
91
91
 
92
92
  it "should allow nested block return values" do
@@ -97,7 +97,7 @@ module RubySpeech
97
97
  end
98
98
  expected_doc = GRXML::Grammar.new doc
99
99
  expected_doc << GRXML::Rule.new(doc, :scope => :public, :id => :main, :content => "Hello Fred")
100
- drawn_doc.should == expected_doc
100
+ expect(drawn_doc).to eq(expected_doc)
101
101
  end
102
102
 
103
103
  it "should allow nested GRXML elements" do
@@ -117,7 +117,7 @@ module RubySpeech
117
117
  rule << oneof
118
118
  expected_doc = GRXML::Grammar.new doc
119
119
  expected_doc << rule
120
- drawn_doc.should == expected_doc
120
+ expect(drawn_doc).to eq(expected_doc)
121
121
  end
122
122
 
123
123
  # TODO: maybe turn a rule embedded in anthoer rule into a ruleref??
@@ -157,7 +157,7 @@ module RubySpeech
157
157
  end
158
158
 
159
159
  it "should embed the document" do
160
- doc2.should == expected_doc
160
+ expect(doc2).to eq(expected_doc)
161
161
  end
162
162
 
163
163
  context "of different modes (dtmf in voice or vice-versa)" do
@@ -176,7 +176,7 @@ module RubySpeech
176
176
  end
177
177
 
178
178
  it "should raise an exception" do
179
- lambda { voice_doc }.should raise_error(GRXML::InvalidChildError, "Embedded grammars must have the same mode")
179
+ expect { voice_doc }.to raise_error(GRXML::InvalidChildError, "Embedded grammars must have the same mode")
180
180
  end
181
181
  end
182
182
  end
@@ -198,7 +198,7 @@ module RubySpeech
198
198
  end
199
199
  end
200
200
 
201
- doc.should == expected_doc
201
+ expect(doc).to eq(expected_doc)
202
202
  end
203
203
 
204
204
  it "strings" do
@@ -216,7 +216,7 @@ module RubySpeech
216
216
  end
217
217
  end
218
218
 
219
- doc.should == expected_doc
219
+ expect(doc).to eq(expected_doc)
220
220
  end
221
221
  end
222
222
 
@@ -230,7 +230,7 @@ module RubySpeech
230
230
  3.times do
231
231
  expected_doc << GRXML::Rule.new(doc, :native_content => "I <3 nachos.")
232
232
  end
233
- drawn_doc.should == expected_doc
233
+ expect(drawn_doc).to eq(expected_doc)
234
234
  end
235
235
 
236
236
  # TODO: verfify rule is in document if named in a ruleref
@@ -242,7 +242,7 @@ module RubySpeech
242
242
  string "HELLO?"
243
243
  item :weight => 2.5
244
244
  one_of do
245
- item { "1" }
245
+ item { string 1 }
246
246
  item { "2" }
247
247
  end
248
248
  ruleref :uri => '#test'
@@ -285,7 +285,7 @@ module RubySpeech
285
285
  oneof << GRXML::Item.new(doc, :content => "single item")
286
286
  rule << oneof
287
287
  expected_doc << rule
288
- drawn_doc.should == expected_doc
288
+ expect(drawn_doc).to eq(expected_doc)
289
289
  end
290
290
 
291
291
  describe "importing nested tags" do
@@ -307,10 +307,10 @@ module RubySpeech
307
307
  subject { import }
308
308
 
309
309
  it "should work" do
310
- lambda { subject }.should_not raise_error
310
+ expect { subject }.not_to raise_error
311
311
  end
312
312
 
313
- it { should be_a GRXML::Grammar }
313
+ it { is_expected.to be_a GRXML::Grammar }
314
314
 
315
315
  its(:children) { should == [rule] }
316
316
 
@@ -331,7 +331,7 @@ module RubySpeech
331
331
  tag = GRXML::Tag.new doc
332
332
  item << tag
333
333
 
334
- item.children(:item, :weight => 0.5).should == [item1]
334
+ expect(item.children(:item, :weight => 0.5)).to eq([item1])
335
335
  end
336
336
 
337
337
  it "should be able to traverse up the tree" do
@@ -344,13 +344,13 @@ module RubySpeech
344
344
  end
345
345
 
346
346
  rule = grammar.children.first
347
- rule.parent.should == grammar
347
+ expect(rule.parent).to eq(grammar)
348
348
 
349
349
  item = rule.children.first
350
- item.parent.should == rule
350
+ expect(item.parent).to eq(rule)
351
351
 
352
352
  text = item.nokogiri_children.first
353
- text.parent.should == item
353
+ expect(text.parent).to eq(item)
354
354
  end
355
355
  end
356
356
  end # GRXML
@@ -52,7 +52,23 @@ describe RubySpeech::NLSML do
52
52
  end
53
53
  end
54
54
 
55
- document.to_xml.should == expected_document
55
+ expect(document.to_xml).to eq(expected_document)
56
+ end
57
+
58
+ it "should return a structured/parsed document" do
59
+ document = RubySpeech::NLSML.draw(grammar: 'http://flight') do
60
+ interpretation confidence: 0.6 do
61
+ input "I want to go to Pittsburgh", mode: :speech
62
+
63
+ instance do
64
+ airline do
65
+ to_city 'Pittsburgh'
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ expect(document).to be_match
56
72
  end
57
73
 
58
74
  context "with a string instance" do
@@ -76,7 +92,7 @@ describe RubySpeech::NLSML do
76
92
  end
77
93
  end
78
94
 
79
- document.to_xml.should == expected_document
95
+ expect(document.to_xml).to eq(expected_document)
80
96
  end
81
97
  end
82
98
  end
@@ -90,7 +106,7 @@ describe RubySpeech::NLSML do
90
106
 
91
107
  its(:grammar) { should == 'http://flight' }
92
108
 
93
- it { should be_match }
109
+ it { is_expected.to be_match }
94
110
 
95
111
  let(:expected_best_interpretation) do
96
112
  {
@@ -117,11 +133,11 @@ describe RubySpeech::NLSML do
117
133
  its(:best_interpretation) { should == expected_best_interpretation }
118
134
 
119
135
  it "should be equal if the XML is the same" do
120
- subject.should be == RubySpeech.parse(example_document)
136
+ expect(subject).to eq(RubySpeech.parse(example_document))
121
137
  end
122
138
 
123
139
  it "should not be equal if the XML is different" do
124
- subject.should_not be == RubySpeech.parse(empty_result)
140
+ expect(subject).not_to eq(RubySpeech.parse(empty_result))
125
141
  end
126
142
 
127
143
  context "when the XML is already parsed and is not the root of a document" do
@@ -198,6 +214,38 @@ describe RubySpeech::NLSML do
198
214
  its(:best_interpretation) { should == expected_best_interpretation }
199
215
  end
200
216
 
217
+ context "with an interpretation that has no input" do
218
+ let :example_document do
219
+ '''
220
+ <result xmlns="http://www.ietf.org/xml/ns/mrcpv2" grammar="http://flight">
221
+ <interpretation confidence="0.6">
222
+ <instance>
223
+ <airline>
224
+ <to_city>Pittsburgh</to_city>
225
+ </airline>
226
+ </instance>
227
+ </interpretation>
228
+ </result>
229
+ '''
230
+ end
231
+
232
+ let(:expected_best_interpretation) do
233
+ {
234
+ confidence: 0.6,
235
+ input: nil,
236
+ instance: { airline: { to_city: 'Pittsburgh' } },
237
+ instances: [{ airline: { to_city: 'Pittsburgh' } }]
238
+ }
239
+ end
240
+
241
+ let(:expected_interpretations) do
242
+ [expected_best_interpretation]
243
+ end
244
+
245
+ its(:interpretations) { should == expected_interpretations }
246
+ its(:best_interpretation) { should == expected_best_interpretation }
247
+ end
248
+
201
249
  context "with a string instance" do
202
250
  let :example_document do
203
251
  '''
@@ -232,7 +280,7 @@ describe RubySpeech::NLSML do
232
280
  RubySpeech.parse empty_result
233
281
  end
234
282
 
235
- it { should_not be_match }
283
+ it { is_expected.not_to be_match }
236
284
  end
237
285
 
238
286
  context "with interpretations out of confidence order" do
@@ -341,7 +389,7 @@ describe RubySpeech::NLSML do
341
389
  '''
342
390
  end
343
391
 
344
- it { should_not be_match }
392
+ it { is_expected.not_to be_match }
345
393
  end
346
394
 
347
395
  context "with multiple interpretations where one is a nomatch input" do
@@ -365,7 +413,7 @@ describe RubySpeech::NLSML do
365
413
  '''
366
414
  end
367
415
 
368
- it { should be_match }
416
+ it { is_expected.to be_match }
369
417
  end
370
418
 
371
419
  context "with a single interpretation with a noinput" do
@@ -381,8 +429,8 @@ describe RubySpeech::NLSML do
381
429
  '''
382
430
  end
383
431
 
384
- it { should_not be_match }
385
- it { should be_noinput }
432
+ it { is_expected.not_to be_match }
433
+ it { is_expected.to be_noinput }
386
434
  end
387
435
  end
388
436
  end