ruby_speech 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +11 -23
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/Rakefile +2 -0
- data/lib/ruby_speech/version.rb +1 -1
- data/ruby_speech.gemspec +3 -3
- data/spec/ruby_speech/grxml/builtins_spec.rb +72 -72
- data/spec/ruby_speech/grxml/grammar_spec.rb +37 -37
- data/spec/ruby_speech/grxml/item_spec.rb +33 -33
- data/spec/ruby_speech/grxml/match_spec.rb +1 -1
- data/spec/ruby_speech/grxml/matcher_spec.rb +62 -62
- data/spec/ruby_speech/grxml/max_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/no_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/one_of_spec.rb +6 -6
- data/spec/ruby_speech/grxml/potential_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/rule_spec.rb +17 -17
- data/spec/ruby_speech/grxml/ruleref_spec.rb +10 -10
- data/spec/ruby_speech/grxml/tag_spec.rb +5 -5
- data/spec/ruby_speech/grxml/token_spec.rb +7 -7
- data/spec/ruby_speech/grxml_spec.rb +24 -24
- data/spec/ruby_speech/nlsml_spec.rb +11 -11
- data/spec/ruby_speech/ssml/audio_spec.rb +19 -19
- data/spec/ruby_speech/ssml/break_spec.rb +16 -16
- data/spec/ruby_speech/ssml/desc_spec.rb +7 -7
- data/spec/ruby_speech/ssml/emphasis_spec.rb +21 -21
- data/spec/ruby_speech/ssml/mark_spec.rb +5 -5
- data/spec/ruby_speech/ssml/p_spec.rb +17 -17
- data/spec/ruby_speech/ssml/phoneme_spec.rb +8 -8
- data/spec/ruby_speech/ssml/prosody_spec.rb +61 -61
- data/spec/ruby_speech/ssml/s_spec.rb +16 -16
- data/spec/ruby_speech/ssml/say_as_spec.rb +9 -9
- data/spec/ruby_speech/ssml/speak_spec.rb +29 -29
- data/spec/ruby_speech/ssml/sub_spec.rb +7 -7
- data/spec/ruby_speech/ssml/voice_spec.rb +31 -31
- data/spec/ruby_speech/ssml_spec.rb +20 -20
- data/spec/ruby_speech_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- data/spec/support/grammar_matchers.rb +6 -6
- data/spec/support/match_examples.rb +5 -5
- data/spec/support/matchers.rb +1 -1
- metadata +17 -11
@@ -5,11 +5,11 @@ module RubySpeech
|
|
5
5
|
describe MaxMatch do
|
6
6
|
it_behaves_like "match"
|
7
7
|
|
8
|
-
it {
|
8
|
+
it { is_expected.to be_a Match }
|
9
9
|
|
10
10
|
describe "equality" do
|
11
11
|
it "should never be equal to a MaxMatch" do
|
12
|
-
described_class.new.
|
12
|
+
expect(described_class.new).not_to eql(Match.new)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module RubySpeech
|
|
5
5
|
describe NoMatch do
|
6
6
|
describe "equality" do
|
7
7
|
it "should be equal to another NoMatch" do
|
8
|
-
NoMatch.new.
|
8
|
+
expect(NoMatch.new).to eq(NoMatch.new)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should not equal a match" do
|
12
|
-
NoMatch.new.
|
12
|
+
expect(NoMatch.new).not_to eq(Match.new)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -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').
|
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 {
|
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
|
-
|
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
|
-
|
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").
|
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").
|
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.
|
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.
|
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).
|
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 {
|
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
|
-
|
58
|
-
|
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
|
-
|
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").
|
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").
|
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").
|
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).
|
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).
|
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
|
-
|
98
|
+
expect { subject << 'anything' }.not_to raise_error
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should accept OneOf" do
|
102
|
-
|
102
|
+
expect { subject << OneOf.new(doc) }.not_to raise_error
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should accept Item" do
|
106
|
-
|
106
|
+
expect { subject << Item.new(doc) }.not_to raise_error
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should accept Ruleref" do
|
110
|
-
|
110
|
+
expect { subject << Ruleref.new(doc) }.not_to raise_error
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should accept Tag" do
|
114
|
-
|
114
|
+
expect { subject << Tag.new(doc) }.not_to raise_error
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should accept Token" do
|
118
|
-
|
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
|
-
|
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).
|
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 {
|
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
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
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).
|
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 {
|
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").
|
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").
|
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
|
-
|
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).
|
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 {
|
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.
|
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").
|
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").
|
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
|
-
|
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.
|
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").
|
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").
|
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.
|
40
|
-
GRXML.draw.document.xpath('ns:grammar', ns: 'http://www.w3.org/2001/06/grammar').size.
|
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
|
-
|
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.
|
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
|
-
|
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.
|
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.
|
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
|
-
|
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.
|
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.
|
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.
|
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
|
-
|
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.
|
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.
|
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.
|
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
|
@@ -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.
|
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
|
-
|
310
|
+
expect { subject }.not_to raise_error
|
311
311
|
end
|
312
312
|
|
313
|
-
it {
|
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).
|
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.
|
347
|
+
expect(rule.parent).to eq(grammar)
|
348
348
|
|
349
349
|
item = rule.children.first
|
350
|
-
item.parent.
|
350
|
+
expect(item.parent).to eq(rule)
|
351
351
|
|
352
352
|
text = item.nokogiri_children.first
|
353
|
-
text.parent.
|
353
|
+
expect(text.parent).to eq(item)
|
354
354
|
end
|
355
355
|
end
|
356
356
|
end # GRXML
|