ruby_speech 2.3.1 → 3.0.1
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/.hound.yml +2 -0
- data/.travis.yml +25 -9
- data/CHANGELOG.md +19 -1
- data/README.md +14 -15
- data/Rakefile +2 -0
- data/ext/ruby_speech/RubySpeechGRXMLMatcher.java +17 -12
- data/ext/ruby_speech/RubySpeechService.java +1 -1
- data/ext/ruby_speech/extconf.rb +1 -1
- data/lib/ruby_speech/generic_element.rb +2 -2
- data/lib/ruby_speech/grxml/builtins.rb +18 -11
- data/lib/ruby_speech/grxml/grammar.rb +26 -4
- data/lib/ruby_speech/grxml/matcher.rb +2 -2
- data/lib/ruby_speech/grxml.rb +2 -0
- data/lib/ruby_speech/nlsml/builder.rb +2 -1
- data/lib/ruby_speech/nlsml/document.rb +5 -0
- data/lib/ruby_speech/ssml/break.rb +1 -2
- data/lib/ruby_speech/ssml/element.rb +13 -1
- data/lib/ruby_speech/ssml/mark.rb +0 -1
- data/lib/ruby_speech/ssml/prosody.rb +8 -5
- data/lib/ruby_speech/version.rb +1 -1
- data/ruby_speech.gemspec +13 -8
- data/spec/ruby_speech/grxml/builtins_spec.rb +80 -71
- data/spec/ruby_speech/grxml/grammar_spec.rb +168 -34
- 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 +103 -59
- 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 +25 -25
- data/spec/ruby_speech/nlsml_spec.rb +58 -10
- data/spec/ruby_speech/ssml/audio_spec.rb +19 -19
- data/spec/ruby_speech/ssml/break_spec.rb +42 -22
- 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 +82 -64
- 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 +41 -17
- data/spec/ruby_speech_spec.rb +3 -3
- data/spec/spec_helper.rb +8 -3
- data/spec/support/dtmf_helper.rb +14 -0
- data/spec/support/grammar_matchers.rb +6 -6
- data/spec/support/match_examples.rb +5 -5
- data/spec/support/matchers.rb +1 -1
- metadata +49 -20
@@ -16,12 +16,12 @@ module RubySpeech
|
|
16
16
|
its(:contour) { should == 'something' }
|
17
17
|
its(:range) { should == '20Hz' }
|
18
18
|
its(:rate) { should == 2 }
|
19
|
-
its(:duration) { should
|
19
|
+
its(:duration) { should eql 10 }
|
20
20
|
its(:volume) { should == :loud }
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'registers itself' do
|
24
|
-
Element.class_from_registration(:prosody).
|
24
|
+
expect(Element.class_from_registration(:prosody)).to eq(Prosody)
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "from a document" do
|
@@ -29,13 +29,13 @@ module RubySpeech
|
|
29
29
|
|
30
30
|
subject { Element.import document }
|
31
31
|
|
32
|
-
it {
|
32
|
+
it { is_expected.to be_instance_of Prosody }
|
33
33
|
|
34
34
|
its(:pitch) { should == :medium }
|
35
35
|
its(:contour) { should == 'something' }
|
36
36
|
its(:range) { should == '20Hz' }
|
37
37
|
its(:rate) { should == 2 }
|
38
|
-
its(:duration) { should
|
38
|
+
its(:duration) { should eql 10 }
|
39
39
|
its(:volume) { should == :loud }
|
40
40
|
end
|
41
41
|
|
@@ -46,16 +46,16 @@ module RubySpeech
|
|
46
46
|
its(:pitch) { should == :medium }
|
47
47
|
|
48
48
|
it "with a valid value" do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
expect { subject.pitch = :'x-low' }.not_to raise_error
|
50
|
+
expect { subject.pitch = :low }.not_to raise_error
|
51
|
+
expect { subject.pitch = :medium }.not_to raise_error
|
52
|
+
expect { subject.pitch = :high }.not_to raise_error
|
53
|
+
expect { subject.pitch = :'x-high' }.not_to raise_error
|
54
|
+
expect { subject.pitch = :default }.not_to raise_error
|
55
55
|
end
|
56
56
|
|
57
57
|
it "with an invalid value" do
|
58
|
-
|
58
|
+
expect { subject.pitch = :something }.to raise_error(ArgumentError, "You must specify a valid pitch (\"[positive-number]Hz\", :\"x-low\", :low, :medium, :high, :\"x-high\", :default)")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -67,11 +67,11 @@ module RubySpeech
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "with a negative value" do
|
70
|
-
|
70
|
+
expect { subject.pitch = "-100Hz" }.to raise_error(ArgumentError, "You must specify a valid pitch (\"[positive-number]Hz\", :\"x-low\", :low, :medium, :high, :\"x-high\", :default)")
|
71
71
|
end
|
72
72
|
|
73
73
|
it "when missing 'hz'" do
|
74
|
-
|
74
|
+
expect { subject.pitch = "440" }.to raise_error(ArgumentError, "You must specify a valid pitch (\"[positive-number]Hz\", :\"x-low\", :low, :medium, :high, :\"x-high\", :default)")
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -89,16 +89,16 @@ module RubySpeech
|
|
89
89
|
its(:range) { should == :medium }
|
90
90
|
|
91
91
|
it "with a valid value" do
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
92
|
+
expect { subject.range = :'x-low' }.not_to raise_error
|
93
|
+
expect { subject.range = :low }.not_to raise_error
|
94
|
+
expect { subject.range = :medium }.not_to raise_error
|
95
|
+
expect { subject.range = :high }.not_to raise_error
|
96
|
+
expect { subject.range = :'x-high' }.not_to raise_error
|
97
|
+
expect { subject.range = :default }.not_to raise_error
|
98
98
|
end
|
99
99
|
|
100
100
|
it "with an invalid value" do
|
101
|
-
|
101
|
+
expect { subject.range = :something }.to raise_error(ArgumentError, "You must specify a valid range (\"[positive-number]Hz\", :\"x-low\", :low, :medium, :high, :\"x-high\", :default)")
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -110,11 +110,11 @@ module RubySpeech
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it "with a negative value" do
|
113
|
-
|
113
|
+
expect { subject.range = "-100Hz" }.to raise_error(ArgumentError, "You must specify a valid range (\"[positive-number]Hz\", :\"x-low\", :low, :medium, :high, :\"x-high\", :default)")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "when missing 'hz'" do
|
117
|
-
|
117
|
+
expect { subject.range = "440" }.to raise_error(ArgumentError, "You must specify a valid range (\"[positive-number]Hz\", :\"x-low\", :low, :medium, :high, :\"x-high\", :default)")
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -126,16 +126,16 @@ module RubySpeech
|
|
126
126
|
its(:rate) { should == :medium }
|
127
127
|
|
128
128
|
it "with a valid value" do
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
129
|
+
expect { subject.rate = :'x-slow' }.not_to raise_error
|
130
|
+
expect { subject.rate = :slow }.not_to raise_error
|
131
|
+
expect { subject.rate = :medium }.not_to raise_error
|
132
|
+
expect { subject.rate = :fast }.not_to raise_error
|
133
|
+
expect { subject.rate = :'x-fast' }.not_to raise_error
|
134
|
+
expect { subject.rate = :default }.not_to raise_error
|
135
135
|
end
|
136
136
|
|
137
137
|
it "with an invalid value" do
|
138
|
-
|
138
|
+
expect { subject.rate = :something }.to raise_error(ArgumentError, "You must specify a valid rate ([positive-number](multiplier), :\"x-slow\", :slow, :medium, :fast, :\"x-fast\", :default)")
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -147,7 +147,25 @@ module RubySpeech
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it "with a negative value" do
|
150
|
-
|
150
|
+
expect { subject.rate = -100 }.to raise_error(ArgumentError, "You must specify a valid rate ([positive-number](multiplier), :\"x-slow\", :slow, :medium, :fast, :\"x-fast\", :default)")
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "with a percentage" do
|
154
|
+
before { subject.rate = "22.5%" }
|
155
|
+
|
156
|
+
its(:rate) { should == "22.5%" }
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "with a percentage and a plus sign" do
|
160
|
+
before { subject.rate = "+22.5%" }
|
161
|
+
|
162
|
+
its(:rate) { should == "+22.5%" }
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "with a percentage and a minus sign" do
|
166
|
+
before { subject.rate = "-22.5%" }
|
167
|
+
|
168
|
+
its(:rate) { should == "-22.5%" }
|
151
169
|
end
|
152
170
|
end
|
153
171
|
end
|
@@ -156,18 +174,18 @@ module RubySpeech
|
|
156
174
|
context "with a valid value" do
|
157
175
|
before { subject.duration = 3 }
|
158
176
|
|
159
|
-
its(:duration) { should
|
177
|
+
its(:duration) { should eql 3 }
|
160
178
|
end
|
161
179
|
|
162
180
|
context "with a negative value" do
|
163
181
|
it do
|
164
|
-
|
182
|
+
expect { subject.duration = -3 }.to raise_error(ArgumentError, "You must specify a valid duration (positive float value in seconds)")
|
165
183
|
end
|
166
184
|
end
|
167
185
|
|
168
186
|
context "with an invalid value" do
|
169
187
|
it do
|
170
|
-
|
188
|
+
expect { subject.duration = 'blah' }.to raise_error(ArgumentError, "You must specify a valid duration (positive float value in seconds)")
|
171
189
|
end
|
172
190
|
end
|
173
191
|
end
|
@@ -179,17 +197,17 @@ module RubySpeech
|
|
179
197
|
its(:volume) { should == :medium }
|
180
198
|
|
181
199
|
it "with a valid value" do
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
200
|
+
expect { subject.volume = :silent }.not_to raise_error
|
201
|
+
expect { subject.volume = :'x-soft' }.not_to raise_error
|
202
|
+
expect { subject.volume = :soft }.not_to raise_error
|
203
|
+
expect { subject.volume = :medium }.not_to raise_error
|
204
|
+
expect { subject.volume = :loud }.not_to raise_error
|
205
|
+
expect { subject.volume = :'x-loud' }.not_to raise_error
|
206
|
+
expect { subject.volume = :default }.not_to raise_error
|
189
207
|
end
|
190
208
|
|
191
209
|
it "with an invalid value" do
|
192
|
-
|
210
|
+
expect { subject.volume = :something }.to raise_error(ArgumentError, "You must specify a valid volume ([positive-number](0.0 -> 100.0), :silent, :\"x-soft\", :soft, :medium, :loud, :\"x-loud\", :default)")
|
193
211
|
end
|
194
212
|
end
|
195
213
|
|
@@ -201,111 +219,111 @@ module RubySpeech
|
|
201
219
|
end
|
202
220
|
|
203
221
|
it "with a negative value" do
|
204
|
-
|
205
|
-
|
222
|
+
expect { subject.volume = -1.5 }.to raise_error(ArgumentError, "You must specify a valid volume ([positive-number](0.0 -> 100.0), :silent, :\"x-soft\", :soft, :medium, :loud, :\"x-loud\", :default)")
|
223
|
+
expect { subject.volume = 100.5 }.to raise_error(ArgumentError, "You must specify a valid volume ([positive-number](0.0 -> 100.0), :silent, :\"x-soft\", :soft, :medium, :loud, :\"x-loud\", :default)")
|
206
224
|
end
|
207
225
|
end
|
208
226
|
end
|
209
227
|
|
210
228
|
describe "comparing objects" do
|
211
229
|
it "should be equal if the content, strength and base uri are the same" do
|
212
|
-
Prosody.new(doc, :pitch => :medium, :contour => "something", :range => '20Hz', :rate => 2, :duration => 10, :volume => :loud, :content => "Hello there").
|
230
|
+
expect(Prosody.new(doc, :pitch => :medium, :contour => "something", :range => '20Hz', :rate => 2, :duration => 10, :volume => :loud, :content => "Hello there")).to eq(Prosody.new(doc, :pitch => :medium, :contour => "something", :range => '20Hz', :rate => 2, :duration => 10, :volume => :loud, :content => "Hello there"))
|
213
231
|
end
|
214
232
|
|
215
233
|
describe "when the content is different" do
|
216
234
|
it "should not be equal" do
|
217
|
-
Prosody.new(doc, :content => "Hello").
|
235
|
+
expect(Prosody.new(doc, :content => "Hello")).not_to eq(Prosody.new(doc, :content => "Hello there"))
|
218
236
|
end
|
219
237
|
end
|
220
238
|
|
221
239
|
describe "when the pitch is different" do
|
222
240
|
it "should not be equal" do
|
223
|
-
Prosody.new(doc, :pitch => :medium).
|
241
|
+
expect(Prosody.new(doc, :pitch => :medium)).not_to eq(Prosody.new(doc, :pitch => :high))
|
224
242
|
end
|
225
243
|
end
|
226
244
|
|
227
245
|
describe "when the contour is different" do
|
228
246
|
it "should not be equal" do
|
229
|
-
Prosody.new(doc, :contour => 'foo').
|
247
|
+
expect(Prosody.new(doc, :contour => 'foo')).not_to eq(Prosody.new(doc, :contour => 'bar'))
|
230
248
|
end
|
231
249
|
end
|
232
250
|
|
233
251
|
describe "when the range is different" do
|
234
252
|
it "should not be equal" do
|
235
|
-
Prosody.new(doc, :range => '20Hz').
|
253
|
+
expect(Prosody.new(doc, :range => '20Hz')).not_to eq(Prosody.new(doc, :range => '30Hz'))
|
236
254
|
end
|
237
255
|
end
|
238
256
|
|
239
257
|
describe "when the rate is different" do
|
240
258
|
it "should not be equal" do
|
241
|
-
Prosody.new(doc, :rate => 2).
|
259
|
+
expect(Prosody.new(doc, :rate => 2)).not_to eq(Prosody.new(doc, :rate => 3))
|
242
260
|
end
|
243
261
|
end
|
244
262
|
|
245
263
|
describe "when the duration is different" do
|
246
264
|
it "should not be equal" do
|
247
|
-
Prosody.new(doc, :duration => 10).
|
265
|
+
expect(Prosody.new(doc, :duration => 10)).not_to eq(Prosody.new(doc, :duration => 20))
|
248
266
|
end
|
249
267
|
end
|
250
268
|
|
251
269
|
describe "when the volume is different" do
|
252
270
|
it "should not be equal" do
|
253
|
-
Prosody.new(doc, :volume => :loud).
|
271
|
+
expect(Prosody.new(doc, :volume => :loud)).not_to eq(Prosody.new(doc, :volume => :soft))
|
254
272
|
end
|
255
273
|
end
|
256
274
|
end
|
257
275
|
|
258
276
|
describe "<<" do
|
259
277
|
it "should accept String" do
|
260
|
-
|
278
|
+
expect { subject << 'anything' }.not_to raise_error
|
261
279
|
end
|
262
280
|
|
263
281
|
it "should accept Audio" do
|
264
|
-
|
282
|
+
expect { subject << Audio.new(doc) }.not_to raise_error
|
265
283
|
end
|
266
284
|
|
267
285
|
it "should accept Break" do
|
268
|
-
|
286
|
+
expect { subject << Break.new(doc) }.not_to raise_error
|
269
287
|
end
|
270
288
|
|
271
289
|
it "should accept Emphasis" do
|
272
|
-
|
290
|
+
expect { subject << Emphasis.new(doc) }.not_to raise_error
|
273
291
|
end
|
274
292
|
|
275
293
|
it "should accept Mark" do
|
276
|
-
|
294
|
+
expect { subject << Mark.new(doc) }.not_to raise_error
|
277
295
|
end
|
278
296
|
|
279
297
|
it "should accept P" do
|
280
|
-
|
298
|
+
expect { subject << P.new(doc) }.not_to raise_error
|
281
299
|
end
|
282
300
|
|
283
301
|
it "should accept Phoneme" do
|
284
|
-
|
302
|
+
expect { subject << Phoneme.new(doc) }.not_to raise_error
|
285
303
|
end
|
286
304
|
|
287
305
|
it "should accept Prosody" do
|
288
|
-
|
306
|
+
expect { subject << Prosody.new(doc) }.not_to raise_error
|
289
307
|
end
|
290
308
|
|
291
309
|
it "should accept S" do
|
292
|
-
|
310
|
+
expect { subject << S.new(doc) }.not_to raise_error
|
293
311
|
end
|
294
312
|
|
295
313
|
it "should accept SayAs" do
|
296
|
-
|
314
|
+
expect { subject << SayAs.new(doc, :interpret_as => :foo) }.not_to raise_error
|
297
315
|
end
|
298
316
|
|
299
317
|
it "should accept Sub" do
|
300
|
-
|
318
|
+
expect { subject << Sub.new(doc) }.not_to raise_error
|
301
319
|
end
|
302
320
|
|
303
321
|
it "should accept Voice" do
|
304
|
-
|
322
|
+
expect { subject << Voice.new(doc) }.not_to raise_error
|
305
323
|
end
|
306
324
|
|
307
325
|
it "should raise InvalidChildError with non-acceptable objects" do
|
308
|
-
|
326
|
+
expect { subject << 1 }.to raise_error(InvalidChildError, "A Prosody can only accept String, Audio, Break, Emphasis, Mark, P, Phoneme, Prosody, SayAs, Sub, S, Voice as children")
|
309
327
|
end
|
310
328
|
end
|
311
329
|
end # Prosody
|
@@ -16,7 +16,7 @@ module RubySpeech
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'registers itself' do
|
19
|
-
Element.class_from_registration(:s).
|
19
|
+
expect(Element.class_from_registration(:s)).to eq(S)
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "from a document" do
|
@@ -24,71 +24,71 @@ module RubySpeech
|
|
24
24
|
|
25
25
|
subject { Element.import document }
|
26
26
|
|
27
|
-
it {
|
27
|
+
it { is_expected.to be_instance_of S }
|
28
28
|
its(:content) { should == 'foo' }
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "comparing objects" do
|
32
32
|
it "should be equal if the content and language are the same" do
|
33
|
-
S.new(doc, :language => 'jp', :content => "Hello there").
|
33
|
+
expect(S.new(doc, :language => 'jp', :content => "Hello there")).to eq(S.new(doc, :language => 'jp', :content => "Hello there"))
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "when the content is different" do
|
37
37
|
it "should not be equal" do
|
38
|
-
S.new(doc, :content => "Hello").
|
38
|
+
expect(S.new(doc, :content => "Hello")).not_to eq(S.new(doc, :content => "Hello there"))
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "when the language is different" do
|
43
43
|
it "should not be equal" do
|
44
|
-
S.new(doc, :language => 'jp').
|
44
|
+
expect(S.new(doc, :language => 'jp')).not_to eq(S.new(doc, :language => 'en'))
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "<<" do
|
50
50
|
it "should accept String" do
|
51
|
-
|
51
|
+
expect { subject << 'anything' }.not_to raise_error
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should accept Audio" do
|
55
|
-
|
55
|
+
expect { subject << Audio.new(doc) }.not_to raise_error
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should accept Break" do
|
59
|
-
|
59
|
+
expect { subject << Break.new(doc) }.not_to raise_error
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should accept Emphasis" do
|
63
|
-
|
63
|
+
expect { subject << Emphasis.new(doc) }.not_to raise_error
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should accept Mark" do
|
67
|
-
|
67
|
+
expect { subject << Mark.new(doc) }.not_to raise_error
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should accept Phoneme" do
|
71
|
-
|
71
|
+
expect { subject << Phoneme.new(doc) }.not_to raise_error
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should accept Prosody" do
|
75
|
-
|
75
|
+
expect { subject << Prosody.new(doc) }.not_to raise_error
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should accept SayAs" do
|
79
|
-
|
79
|
+
expect { subject << SayAs.new(doc, :interpret_as => :foo) }.not_to raise_error
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should accept Sub" do
|
83
|
-
|
83
|
+
expect { subject << Sub.new(doc) }.not_to raise_error
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should accept Voice" do
|
87
|
-
|
87
|
+
expect { subject << Voice.new(doc) }.not_to raise_error
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should raise InvalidChildError with non-acceptable objects" do
|
91
|
-
|
91
|
+
expect { subject << 1 }.to raise_error(InvalidChildError, "An S can only accept String, Audio, Break, Emphasis, Mark, Phoneme, Prosody, SayAs, Sub, Voice as children")
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end # S
|
@@ -16,7 +16,7 @@ module RubySpeech
|
|
16
16
|
its(:detail) { should == 'three' }
|
17
17
|
|
18
18
|
it 'registers itself' do
|
19
|
-
Element.class_from_registration(:'say-as').
|
19
|
+
expect(Element.class_from_registration(:'say-as')).to eq(SayAs)
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "from a document" do
|
@@ -24,7 +24,7 @@ module RubySpeech
|
|
24
24
|
|
25
25
|
subject { Element.import document }
|
26
26
|
|
27
|
-
it {
|
27
|
+
it { is_expected.to be_instance_of SayAs }
|
28
28
|
|
29
29
|
its(:interpret_as) { should == 'one' }
|
30
30
|
its(:format) { should == 'two' }
|
@@ -33,41 +33,41 @@ module RubySpeech
|
|
33
33
|
|
34
34
|
describe "comparing objects" do
|
35
35
|
it "should be equal if the content, interpret_as, format, age, variant, name are the same" do
|
36
|
-
SayAs.new(doc, :interpret_as => 'jp', :format => 'foo', :detail => 'bar', :content => "hello").
|
36
|
+
expect(SayAs.new(doc, :interpret_as => 'jp', :format => 'foo', :detail => 'bar', :content => "hello")).to eq(SayAs.new(doc, :interpret_as => 'jp', :format => 'foo', :detail => 'bar', :content => "hello"))
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "when the content is different" do
|
40
40
|
it "should not be equal" do
|
41
|
-
SayAs.new(doc, :interpret_as => 'jp', :content => "Hello").
|
41
|
+
expect(SayAs.new(doc, :interpret_as => 'jp', :content => "Hello")).not_to eq(SayAs.new(doc, :interpret_as => 'jp', :content => "Hello there"))
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "when the interpret_as is different" do
|
46
46
|
it "should not be equal" do
|
47
|
-
SayAs.new(doc, :interpret_as => "Hello").
|
47
|
+
expect(SayAs.new(doc, :interpret_as => "Hello")).not_to eq(SayAs.new(doc, :interpret_as => "Hello there"))
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "when the format is different" do
|
52
52
|
it "should not be equal" do
|
53
|
-
SayAs.new(doc, :interpret_as => 'jp', :format => 'foo').
|
53
|
+
expect(SayAs.new(doc, :interpret_as => 'jp', :format => 'foo')).not_to eq(SayAs.new(doc, :interpret_as => 'jp', :format => 'bar'))
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "when the detail is different" do
|
58
58
|
it "should not be equal" do
|
59
|
-
SayAs.new(doc, :interpret_as => 'jp', :detail => 'foo').
|
59
|
+
expect(SayAs.new(doc, :interpret_as => 'jp', :detail => 'foo')).not_to eq(SayAs.new(doc, :interpret_as => 'jp', :detail => 'bar'))
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "<<" do
|
65
65
|
it "should accept String" do
|
66
|
-
|
66
|
+
expect { subject << 'anything' }.not_to raise_error
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should raise InvalidChildError with non-acceptable objects" do
|
70
|
-
|
70
|
+
expect { subject << Voice.new(doc) }.to raise_error(InvalidChildError, "A SayAs can only accept Strings as children")
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end # SayAs
|