ruby_speech 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1e98208cd9f5203d85d2612483be8bfc76129aa07c355337a27031dc23170f2c
|
4
|
+
data.tar.gz: 91eeff37a2b0554849485ecc1717ac8f501dc056b1f1e5c9f4617f0fa103637c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 428108a63ca40aaab78165237b4d1bfeb12f7c2097bdc567a234c111b609a5450bfff09ec0e257c91a97405645a0acd8a1c7d5a90754a857d57a2849d4670c48
|
7
|
+
data.tar.gz: 158cf43762cf1fc1180edbf5f4acf28f263859d03801eb54b6a62fd05c1fdee9e1eee75b170aac6dee175a4b872a4adc27f8749e10b82779fd43d6348950bd8b
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,27 +1,17 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
2
|
+
rvm:
|
3
|
+
- 2.1.10
|
4
|
+
- 2.2.10
|
5
|
+
- 2.3.7
|
6
|
+
- 2.4.4
|
7
|
+
- jruby-9.1.17.0
|
8
|
+
- jruby-head
|
9
|
+
- rbx-3
|
10
|
+
- ruby-head
|
11
|
+
jdk:
|
12
|
+
- openjdk8 # for jruby
|
3
13
|
matrix:
|
4
|
-
include:
|
5
|
-
- rvm: 1.9.3
|
6
|
-
- rvm: 2.0.0
|
7
|
-
- rvm: 2.1.0
|
8
|
-
- rvm: 2.2.0
|
9
|
-
- rvm: 2.3.0
|
10
|
-
- rvm: rbx-2
|
11
|
-
- rvm: rbx-3
|
12
|
-
- rvm: ruby-head
|
13
|
-
- rvm: jruby-1.7
|
14
|
-
jdk: openjdk7
|
15
|
-
- rvm: jruby-1.7
|
16
|
-
jdk: oraclejdk8
|
17
|
-
- rvm: jruby-head
|
18
|
-
jdk: oraclejdk8
|
19
|
-
- rvm: jruby-9.1.13.0
|
20
|
-
jdk: openjdk7
|
21
|
-
- rvm: jruby-9.1.13.0
|
22
|
-
jdk: oraclejdk8
|
23
14
|
allow_failures:
|
24
|
-
- rvm: rbx-2
|
25
15
|
- rvm: rbx-3
|
26
16
|
- rvm: ruby-head
|
27
17
|
sudo: false
|
@@ -32,7 +22,5 @@ addons:
|
|
32
22
|
- libpcre3-dev
|
33
23
|
before_install:
|
34
24
|
- gem install bundler
|
35
|
-
env: JRUBY_OPTS="--server --debug -J-Xss1024k -J-Xmx652m -J-XX:+UseConcMarkSweepGC"
|
36
|
-
|
37
25
|
notifications:
|
38
26
|
irc: "irc.freenode.org#adhearsion"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# [develop](https://github.com/benlangfeld/ruby_speech)
|
2
2
|
|
3
|
+
# [3.0.0](https://github.com/benlangfeld/ruby_speech/compare/v2.4.0...v3.0.0) - [2018-07-10](https://rubygems.org/gems/ruby_speech/versions/3.0.0)
|
4
|
+
* Feature: Loosen and bump Nokogiri version to ~>1.8, >=1.8.3
|
5
|
+
* Feature: Bump RSpec to 3.x and convert specs with Transpec
|
6
|
+
|
3
7
|
# [2.4.0](https://github.com/benlangfeld/ruby_speech/compare/v2.3.2...v2.4.0) - [2018-02-23](https://rubygems.org/gems/ruby_speech/versions/2.4.0)
|
4
8
|
* Feature: Permit percentage rate values for prosody tags
|
5
9
|
* Bugfix: Rulerefs referenced n-levels deep under Rulerefs should be expanded.
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/ruby_speech/version.rb
CHANGED
data/ruby_speech.gemspec
CHANGED
@@ -27,15 +27,15 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.extensions = ['ext/ruby_speech/extconf.rb']
|
28
28
|
end
|
29
29
|
|
30
|
-
s.add_runtime_dependency %q<nokogiri>, ["~> 1.
|
30
|
+
s.add_runtime_dependency %q<nokogiri>, ["~> 1.8", ">= 1.8.3"]
|
31
31
|
s.add_runtime_dependency %q<activesupport>, [">= 3.0.7", "< 5.0.0"]
|
32
32
|
|
33
33
|
s.add_development_dependency %q<bundler>, [">= 1.0.0"]
|
34
|
-
s.add_development_dependency %q<rspec>, ["~>
|
34
|
+
s.add_development_dependency %q<rspec>, ["~> 3.0"]
|
35
35
|
s.add_development_dependency %q<rspec-its>, [">= 0"]
|
36
36
|
s.add_development_dependency %q<ci_reporter>, ["~> 1.6"]
|
37
37
|
s.add_development_dependency %q<yard>, [">= 0.7.0"]
|
38
|
-
s.add_development_dependency %q<rake>, ["
|
38
|
+
s.add_development_dependency %q<rake>, [">= 0"]
|
39
39
|
s.add_development_dependency %q<guard>, [">= 0.9.0"]
|
40
40
|
s.add_development_dependency %q<guard-rspec>, [">= 0"]
|
41
41
|
s.add_development_dependency %q<listen>, ["< 3.1.0"]
|
@@ -4,22 +4,22 @@ describe RubySpeech::GRXML::Builtins do
|
|
4
4
|
describe "boolean" do
|
5
5
|
subject(:grammar) { described_class.boolean }
|
6
6
|
|
7
|
-
it {
|
8
|
-
it {
|
7
|
+
it { is_expected.to max_match('1').and_interpret_as('true') }
|
8
|
+
it { is_expected.to max_match('2').and_interpret_as('false') }
|
9
9
|
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
10
|
+
it { is_expected.to not_match('0') }
|
11
|
+
it { is_expected.to not_match('3') }
|
12
|
+
it { is_expected.to not_match('10') }
|
13
13
|
|
14
14
|
context "with the true/false digits parameterized" do
|
15
15
|
subject { described_class.boolean y: 3, n: 7 }
|
16
16
|
|
17
|
-
it {
|
18
|
-
it {
|
17
|
+
it { is_expected.to max_match('3').and_interpret_as('true') }
|
18
|
+
it { is_expected.to max_match('7').and_interpret_as('false') }
|
19
19
|
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
20
|
+
it { is_expected.to not_match('1') }
|
21
|
+
it { is_expected.to not_match('2') }
|
22
|
+
it { is_expected.to not_match('4') }
|
23
23
|
|
24
24
|
context "both the same" do
|
25
25
|
it "should raise ArgumentError" do
|
@@ -32,54 +32,54 @@ describe RubySpeech::GRXML::Builtins do
|
|
32
32
|
describe "date" do
|
33
33
|
subject(:grammar) { described_class.date }
|
34
34
|
|
35
|
-
it {
|
35
|
+
it { is_expected.to max_match('20130929').and_interpret_as('dtmf-2 dtmf-0 dtmf-1 dtmf-3 dtmf-0 dtmf-9 dtmf-2 dtmf-9') }
|
36
36
|
|
37
|
-
it {
|
38
|
-
it {
|
39
|
-
it {
|
40
|
-
it {
|
37
|
+
it { is_expected.to potentially_match('130929') }
|
38
|
+
it { is_expected.to potentially_match('0929') }
|
39
|
+
it { is_expected.to potentially_match('29') }
|
40
|
+
it { is_expected.to potentially_match('1') }
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "digits" do
|
44
44
|
subject(:grammar) { described_class.digits }
|
45
45
|
|
46
|
-
it {
|
47
|
-
it {
|
48
|
-
it {
|
46
|
+
it { is_expected.to match('1').and_interpret_as('dtmf-1') }
|
47
|
+
it { is_expected.to match('123').and_interpret_as('dtmf-1 dtmf-2 dtmf-3') }
|
48
|
+
it { is_expected.to match('1').and_interpret_as('dtmf-1') }
|
49
49
|
|
50
50
|
context "with a minimum length" do
|
51
51
|
subject { described_class.digits minlength: 3 }
|
52
52
|
|
53
|
-
it {
|
54
|
-
it {
|
53
|
+
it { is_expected.to match('123').and_interpret_as('dtmf-1 dtmf-2 dtmf-3') }
|
54
|
+
it { is_expected.to match('1234567890').and_interpret_as('dtmf-1 dtmf-2 dtmf-3 dtmf-4 dtmf-5 dtmf-6 dtmf-7 dtmf-8 dtmf-9 dtmf-0') }
|
55
55
|
|
56
|
-
it {
|
57
|
-
it {
|
58
|
-
it {
|
56
|
+
it { is_expected.to potentially_match('1') }
|
57
|
+
it { is_expected.to potentially_match('11') }
|
58
|
+
it { is_expected.to potentially_match('4') }
|
59
59
|
end
|
60
60
|
|
61
61
|
context "with a maximum length" do
|
62
62
|
subject { described_class.digits maxlength: 3 }
|
63
63
|
|
64
|
-
it {
|
65
|
-
it {
|
66
|
-
it {
|
64
|
+
it { is_expected.to match('1').and_interpret_as('dtmf-1') }
|
65
|
+
it { is_expected.to match('12').and_interpret_as('dtmf-1 dtmf-2') }
|
66
|
+
it { is_expected.to match('123').and_interpret_as('dtmf-1 dtmf-2 dtmf-3') }
|
67
67
|
|
68
|
-
it {
|
69
|
-
it {
|
68
|
+
it { is_expected.to not_match('1111') }
|
69
|
+
it { is_expected.to not_match('1111111') }
|
70
70
|
end
|
71
71
|
|
72
72
|
context "with an absolute length" do
|
73
73
|
subject { described_class.digits length: 3 }
|
74
74
|
|
75
|
-
it {
|
76
|
-
it {
|
75
|
+
it { is_expected.to max_match('123').and_interpret_as('dtmf-1 dtmf-2 dtmf-3') }
|
76
|
+
it { is_expected.to max_match('111').and_interpret_as('dtmf-1 dtmf-1 dtmf-1') }
|
77
77
|
|
78
|
-
it {
|
79
|
-
it {
|
78
|
+
it { is_expected.to potentially_match('1') }
|
79
|
+
it { is_expected.to potentially_match('12') }
|
80
80
|
|
81
|
-
it {
|
82
|
-
it {
|
81
|
+
it { is_expected.to not_match('1234') }
|
82
|
+
it { is_expected.to not_match('12345') }
|
83
83
|
end
|
84
84
|
|
85
85
|
context "when the min and max lengths are swapped" do
|
@@ -104,71 +104,71 @@ describe RubySpeech::GRXML::Builtins do
|
|
104
104
|
describe "currency" do
|
105
105
|
subject(:grammar) { described_class.currency }
|
106
106
|
|
107
|
-
it {
|
108
|
-
it {
|
109
|
-
it {
|
110
|
-
it {
|
111
|
-
it {
|
107
|
+
it { is_expected.to max_match('1*01').and_interpret_as('dtmf-1 dtmf-star dtmf-0 dtmf-1') }
|
108
|
+
it { is_expected.to max_match('01*00').and_interpret_as('dtmf-0 dtmf-1 dtmf-star dtmf-0 dtmf-0') }
|
109
|
+
it { is_expected.to max_match('100000000000*00').and_interpret_as('dtmf-1 dtmf-0 dtmf-0 dtmf-0 dtmf-0 dtmf-0 dtmf-0 dtmf-0 dtmf-0 dtmf-0 dtmf-0 dtmf-0 dtmf-star dtmf-0 dtmf-0') }
|
110
|
+
it { is_expected.to max_match('0*08').and_interpret_as('dtmf-0 dtmf-star dtmf-0 dtmf-8') }
|
111
|
+
it { is_expected.to max_match('*59').and_interpret_as('dtmf-star dtmf-5 dtmf-9') }
|
112
112
|
|
113
|
-
it {
|
114
|
-
it {
|
115
|
-
it {
|
116
|
-
it {
|
117
|
-
it {
|
113
|
+
it { is_expected.to match('0').and_interpret_as('dtmf-0') }
|
114
|
+
it { is_expected.to match('0*0').and_interpret_as('dtmf-0 dtmf-star dtmf-0') }
|
115
|
+
it { is_expected.to match('10*5').and_interpret_as('dtmf-1 dtmf-0 dtmf-star dtmf-5') }
|
116
|
+
it { is_expected.to match('123').and_interpret_as('dtmf-1 dtmf-2 dtmf-3') }
|
117
|
+
it { is_expected.to match('123*').and_interpret_as('dtmf-1 dtmf-2 dtmf-3 dtmf-star') }
|
118
118
|
|
119
|
-
it {
|
119
|
+
it { is_expected.to not_match('#') }
|
120
120
|
end
|
121
121
|
|
122
122
|
describe 'number' do
|
123
123
|
subject(:grammar) { described_class.number }
|
124
124
|
|
125
|
-
it {
|
126
|
-
it {
|
127
|
-
it {
|
128
|
-
it {
|
125
|
+
it { is_expected.to match('0').and_interpret_as 'dtmf-0' }
|
126
|
+
it { is_expected.to match('123').and_interpret_as 'dtmf-1 dtmf-2 dtmf-3' }
|
127
|
+
it { is_expected.to match('1*01').and_interpret_as dtmf_seq %w(1 star 0 1) }
|
128
|
+
it { is_expected.to match('01*00').and_interpret_as dtmf_seq %w(0 1 star 0 0) }
|
129
129
|
it do
|
130
|
-
|
130
|
+
is_expected.to match('100000000000*00')
|
131
131
|
.and_interpret_as dtmf_seq %w(1 0 0 0 0 0 0 0 0 0 0 0 star 0 0)
|
132
132
|
end
|
133
|
-
it {
|
134
|
-
it {
|
135
|
-
it {
|
136
|
-
it {
|
137
|
-
it {
|
133
|
+
it { is_expected.to match('0*08').and_interpret_as dtmf_seq %w(0 star 0 8) }
|
134
|
+
it { is_expected.to match('*59').and_interpret_as 'dtmf-star dtmf-5 dtmf-9' }
|
135
|
+
it { is_expected.to match('0*0').and_interpret_as 'dtmf-0 dtmf-star dtmf-0' }
|
136
|
+
it { is_expected.to match('10*5').and_interpret_as dtmf_seq %w(1 0 star 5) }
|
137
|
+
it { is_expected.to match('123*').and_interpret_as dtmf_seq %w(1 2 3 star) }
|
138
138
|
it do
|
139
|
-
|
139
|
+
is_expected.to match('123*2342').and_interpret_as dtmf_seq %w(1 2 3 star 2 3 4 2)
|
140
140
|
end
|
141
141
|
|
142
|
-
it {
|
142
|
+
it { is_expected.to potentially_match '*' }
|
143
143
|
|
144
|
-
it {
|
145
|
-
it {
|
146
|
-
it {
|
144
|
+
it { is_expected.to not_match '#' }
|
145
|
+
it { is_expected.to not_match '**' }
|
146
|
+
it { is_expected.to not_match '0123*456*789' }
|
147
147
|
end
|
148
148
|
|
149
149
|
describe "phone" do
|
150
150
|
subject(:grammar) { described_class.phone }
|
151
151
|
|
152
|
-
it {
|
153
|
-
it {
|
154
|
-
it {
|
152
|
+
it { is_expected.to match('0').and_interpret_as('dtmf-0') }
|
153
|
+
it { is_expected.to match('0123').and_interpret_as('dtmf-0 dtmf-1 dtmf-2 dtmf-3') }
|
154
|
+
it { is_expected.to match('0123*456').and_interpret_as('dtmf-0 dtmf-1 dtmf-2 dtmf-3 dtmf-star dtmf-4 dtmf-5 dtmf-6') }
|
155
155
|
|
156
|
-
it {
|
156
|
+
it { is_expected.to potentially_match('') }
|
157
157
|
|
158
|
-
it {
|
159
|
-
it {
|
158
|
+
it { is_expected.to not_match('#') }
|
159
|
+
it { is_expected.to not_match('0123*456*789') }
|
160
160
|
end
|
161
161
|
|
162
162
|
describe "time" do
|
163
163
|
subject(:grammar) { described_class.time }
|
164
164
|
|
165
|
-
it {
|
165
|
+
it { is_expected.to max_match('1235').and_interpret_as('dtmf-1 dtmf-2 dtmf-3 dtmf-5') }
|
166
166
|
|
167
|
-
it {
|
168
|
-
it {
|
169
|
-
it {
|
167
|
+
it { is_expected.to match('12').and_interpret_as('dtmf-1 dtmf-2') }
|
168
|
+
it { is_expected.to match('4').and_interpret_as('dtmf-4') }
|
169
|
+
it { is_expected.to match('123').and_interpret_as('dtmf-1 dtmf-2 dtmf-3') }
|
170
170
|
|
171
|
-
it {
|
172
|
-
it {
|
171
|
+
it { is_expected.to not_match('*') }
|
172
|
+
it { is_expected.to not_match('#') }
|
173
173
|
end
|
174
174
|
end
|
@@ -7,7 +7,7 @@ module RubySpeech
|
|
7
7
|
|
8
8
|
subject { described_class.new doc }
|
9
9
|
|
10
|
-
it {
|
10
|
+
it { is_expected.to be_a_valid_grxml_document }
|
11
11
|
|
12
12
|
its(:name) { should == 'grammar' }
|
13
13
|
its(:language) { should == 'en-US' }
|
@@ -36,7 +36,7 @@ module RubySpeech
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'registers itself' do
|
39
|
-
Element.class_from_registration(:grammar).
|
39
|
+
expect(Element.class_from_registration(:grammar)).to eq(Grammar)
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "from a document" do
|
@@ -48,7 +48,7 @@ module RubySpeech
|
|
48
48
|
|
49
49
|
subject { Element.import document }
|
50
50
|
|
51
|
-
it {
|
51
|
+
it { is_expected.to be_instance_of Grammar }
|
52
52
|
|
53
53
|
its(:language) { should == 'jp' }
|
54
54
|
its(:base_uri) { should == 'blah' }
|
@@ -70,24 +70,24 @@ module RubySpeech
|
|
70
70
|
|
71
71
|
describe "comparing objects" do
|
72
72
|
it "should be equal if the content, language and base uri are the same" do
|
73
|
-
Grammar.new(doc, :language => 'en-GB', :base_uri => 'blah', :content => "Hello there").
|
73
|
+
expect(Grammar.new(doc, :language => 'en-GB', :base_uri => 'blah', :content => "Hello there")).to eq(Grammar.new(doc, :language => 'en-GB', :base_uri => 'blah', :content => "Hello there"))
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "when the content is different" do
|
77
77
|
it "should not be equal" do
|
78
|
-
Grammar.new(doc, :content => "Hello").
|
78
|
+
expect(Grammar.new(doc, :content => "Hello")).not_to eq(Grammar.new(doc, :content => "Hello there"))
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
describe "when the language is different" do
|
83
83
|
it "should not be equal" do
|
84
|
-
Grammar.new(doc, :language => 'en-US').
|
84
|
+
expect(Grammar.new(doc, :language => 'en-US')).not_to eq(Grammar.new(doc, :language => 'en-GB'))
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
describe "when the base URI is different" do
|
89
89
|
it "should not be equal" do
|
90
|
-
Grammar.new(doc, :base_uri => 'foo').
|
90
|
+
expect(Grammar.new(doc, :base_uri => 'foo')).not_to eq(Grammar.new(doc, :base_uri => 'bar'))
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -98,7 +98,7 @@ module RubySpeech
|
|
98
98
|
g2 = Grammar.new doc
|
99
99
|
g2 << Rule.new(doc, :id => 'main2')
|
100
100
|
|
101
|
-
g1.
|
101
|
+
expect(g1).not_to eq(g2)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -108,32 +108,32 @@ module RubySpeech
|
|
108
108
|
g.rule :id => :main, :scope => 'public'
|
109
109
|
expected_g = Grammar.new doc
|
110
110
|
expected_g << Rule.new(doc, :id => :main, :scope => 'public')
|
111
|
-
g.
|
111
|
+
expect(g).to eq(expected_g)
|
112
112
|
end
|
113
113
|
|
114
114
|
describe "<<" do
|
115
115
|
it "should accept Rule" do
|
116
|
-
|
116
|
+
expect { subject << Rule.new(doc) }.not_to raise_error
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should accept Tag" do
|
120
|
-
|
120
|
+
expect { subject << Tag.new(doc) }.not_to raise_error
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should raise InvalidChildError with non-acceptable objects" do
|
124
|
-
|
124
|
+
expect { subject << 1 }.to raise_error(InvalidChildError, "A Grammar can only accept Rule and Tag as children")
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
128
|
describe "#to_doc" do
|
129
129
|
it "should create an XML document from the grammar" do
|
130
|
-
subject.to_doc.
|
130
|
+
expect(subject.to_doc).to eq(subject.document)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
134
|
describe "#tag_format" do
|
135
135
|
it "should allow setting tag-format identifier" do
|
136
|
-
|
136
|
+
expect { subject.tag_format = "semantics/1.0" }.not_to raise_error
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -152,11 +152,11 @@ module RubySpeech
|
|
152
152
|
expected_concat << Rule.new(doc, :id => 'millie', :scope => 'public', :content => "Hi Millie")
|
153
153
|
|
154
154
|
concat = grammar1 + grammar2
|
155
|
-
grammar1.to_s.
|
156
|
-
grammar2.to_s.
|
157
|
-
concat.
|
158
|
-
concat.document.root.
|
159
|
-
concat.to_s.
|
155
|
+
expect(grammar1.to_s).to eq(grammar1_string)
|
156
|
+
expect(grammar2.to_s).to eq(grammar2_string)
|
157
|
+
expect(concat).to eq(expected_concat)
|
158
|
+
expect(concat.document.root).to eq(concat)
|
159
|
+
expect(concat.to_s).not_to include('default')
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
@@ -167,7 +167,7 @@ module RubySpeech
|
|
167
167
|
foo = GRXML::Rule.new doc, :id => 'foo'
|
168
168
|
grammar << foo
|
169
169
|
|
170
|
-
grammar.root_rule.
|
170
|
+
expect(grammar.root_rule).to eq(foo)
|
171
171
|
end
|
172
172
|
|
173
173
|
describe "inlining rule references" do
|
@@ -224,13 +224,13 @@ module RubySpeech
|
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should be possible in a non-destructive manner" do
|
227
|
-
grammar.inline.
|
228
|
-
grammar.
|
227
|
+
expect(grammar.inline).to eq(inline_grammar)
|
228
|
+
expect(grammar).not_to eq(inline_grammar)
|
229
229
|
end
|
230
230
|
|
231
231
|
it "should be possible in a destructive manner" do
|
232
|
-
grammar.inline
|
233
|
-
grammar.
|
232
|
+
expect(grammar.inline!).to eq(inline_grammar)
|
233
|
+
expect(grammar).to eq(inline_grammar)
|
234
234
|
end
|
235
235
|
|
236
236
|
context 'nested' do
|
@@ -254,7 +254,7 @@ module RubySpeech
|
|
254
254
|
end.inline
|
255
255
|
end
|
256
256
|
|
257
|
-
it {
|
257
|
+
it { is_expected.to eq expected_doc }
|
258
258
|
end
|
259
259
|
|
260
260
|
context '2 levels deep' do
|
@@ -272,7 +272,7 @@ module RubySpeech
|
|
272
272
|
end.inline
|
273
273
|
end
|
274
274
|
|
275
|
-
it {
|
275
|
+
it { is_expected.to eq expected_doc }
|
276
276
|
end
|
277
277
|
|
278
278
|
context '3 levels deep' do
|
@@ -293,7 +293,7 @@ module RubySpeech
|
|
293
293
|
end.inline
|
294
294
|
end
|
295
295
|
|
296
|
-
it {
|
296
|
+
it { is_expected.to eq expected_doc }
|
297
297
|
end
|
298
298
|
|
299
299
|
context 'in a self-referencial infinite loop' do
|
@@ -393,7 +393,7 @@ module RubySpeech
|
|
393
393
|
let(:tokens) { 'hello' }
|
394
394
|
|
395
395
|
it "should tokenize correctly" do
|
396
|
-
|
396
|
+
is_expected.to eq(tokenized_version)
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
@@ -402,7 +402,7 @@ module RubySpeech
|
|
402
402
|
let(:tokens) { ['2'] }
|
403
403
|
|
404
404
|
it "should tokenize correctly" do
|
405
|
-
|
405
|
+
is_expected.to eq(tokenized_version)
|
406
406
|
end
|
407
407
|
end
|
408
408
|
|
@@ -411,7 +411,7 @@ module RubySpeech
|
|
411
411
|
let(:tokens) { ['San Francisco'] }
|
412
412
|
|
413
413
|
it "should tokenize correctly" do
|
414
|
-
|
414
|
+
is_expected.to eq(tokenized_version)
|
415
415
|
end
|
416
416
|
end
|
417
417
|
|
@@ -420,7 +420,7 @@ module RubySpeech
|
|
420
420
|
let(:tokens) { ['hello'] }
|
421
421
|
|
422
422
|
it "should tokenize correctly" do
|
423
|
-
|
423
|
+
is_expected.to eq(tokenized_version)
|
424
424
|
end
|
425
425
|
end
|
426
426
|
|
@@ -429,7 +429,7 @@ module RubySpeech
|
|
429
429
|
let(:tokens) { ['bon', 'voyage'] }
|
430
430
|
|
431
431
|
it "should tokenize correctly" do
|
432
|
-
|
432
|
+
is_expected.to eq(tokenized_version)
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
@@ -438,7 +438,7 @@ module RubySpeech
|
|
438
438
|
let(:tokens) { ['this', 'is', 'a', 'test'] }
|
439
439
|
|
440
440
|
it "should tokenize correctly" do
|
441
|
-
|
441
|
+
is_expected.to eq(tokenized_version)
|
442
442
|
end
|
443
443
|
end
|
444
444
|
|
@@ -447,7 +447,7 @@ module RubySpeech
|
|
447
447
|
let(:tokens) { ['San Francisco'] }
|
448
448
|
|
449
449
|
it "should tokenize correctly" do
|
450
|
-
|
450
|
+
is_expected.to eq(tokenized_version)
|
451
451
|
end
|
452
452
|
end
|
453
453
|
|
@@ -462,7 +462,7 @@ module RubySpeech
|
|
462
462
|
let(:tokens) { ['Welcome', 'to', 'San Francisco', 'Have Fun!'] }
|
463
463
|
|
464
464
|
it "should tokenize correctly" do
|
465
|
-
|
465
|
+
is_expected.to eq(tokenized_version)
|
466
466
|
end
|
467
467
|
end
|
468
468
|
end
|
@@ -483,9 +483,9 @@ module RubySpeech
|
|
483
483
|
end
|
484
484
|
end
|
485
485
|
|
486
|
-
grammar.
|
486
|
+
expect(grammar).not_to eq(normalized_grammar)
|
487
487
|
grammar.normalize_whitespace
|
488
|
-
grammar.
|
488
|
+
expect(grammar).to eq(normalized_grammar)
|
489
489
|
end
|
490
490
|
end
|
491
491
|
end # Grammar
|