ruby_speech 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/CHANGELOG.md +8 -0
- data/README.md +23 -0
- data/ext/ruby_speech/extconf.rb +3 -1
- data/ext/ruby_speech/ruby_speech.c +4 -1
- data/lib/ruby_speech.rb +6 -19
- data/lib/ruby_speech/generic_element.rb +141 -29
- data/lib/ruby_speech/grxml.rb +16 -22
- data/lib/ruby_speech/grxml/element.rb +6 -6
- data/lib/ruby_speech/grxml/grammar.rb +29 -12
- data/lib/ruby_speech/grxml/item.rb +13 -0
- data/lib/ruby_speech/grxml/matcher.rb +5 -1
- data/lib/ruby_speech/grxml/one_of.rb +4 -0
- data/lib/ruby_speech/grxml/rule.rb +10 -0
- data/lib/ruby_speech/grxml/token.rb +3 -0
- data/lib/ruby_speech/nlsml.rb +3 -9
- data/lib/ruby_speech/ssml.rb +20 -22
- data/lib/ruby_speech/ssml/audio.rb +17 -0
- data/lib/ruby_speech/ssml/desc.rb +4 -0
- data/lib/ruby_speech/ssml/element.rb +5 -3
- data/lib/ruby_speech/ssml/emphasis.rb +17 -0
- data/lib/ruby_speech/ssml/mark.rb +2 -0
- data/lib/ruby_speech/ssml/p.rb +21 -0
- data/lib/ruby_speech/ssml/phoneme.rb +2 -0
- data/lib/ruby_speech/ssml/prosody.rb +15 -0
- data/lib/ruby_speech/ssml/s.rb +20 -0
- data/lib/ruby_speech/ssml/say_as.rb +2 -0
- data/lib/ruby_speech/ssml/speak.rb +19 -1
- data/lib/ruby_speech/ssml/sub.rb +2 -0
- data/lib/ruby_speech/ssml/voice.rb +19 -0
- data/lib/ruby_speech/version.rb +1 -1
- data/ruby_speech.gemspec +2 -3
- data/spec/ruby_speech/grxml/grammar_spec.rb +35 -30
- data/spec/ruby_speech/grxml/item_spec.rb +8 -6
- data/spec/ruby_speech/grxml/one_of_spec.rb +7 -3
- data/spec/ruby_speech/grxml/rule_spec.rb +14 -12
- data/spec/ruby_speech/grxml/ruleref_spec.rb +5 -3
- data/spec/ruby_speech/grxml/tag_spec.rb +6 -2
- data/spec/ruby_speech/grxml/token_spec.rb +6 -2
- data/spec/ruby_speech/grxml_spec.rb +57 -69
- data/spec/ruby_speech/ssml/audio_spec.rb +20 -16
- data/spec/ruby_speech/ssml/break_spec.rb +14 -10
- data/spec/ruby_speech/ssml/desc_spec.rb +9 -5
- data/spec/ruby_speech/ssml/emphasis_spec.rb +17 -13
- data/spec/ruby_speech/ssml/mark_spec.rb +7 -3
- data/spec/ruby_speech/ssml/p_spec.rb +18 -14
- data/spec/ruby_speech/ssml/phoneme_spec.rb +10 -6
- data/spec/ruby_speech/ssml/prosody_spec.rb +29 -25
- data/spec/ruby_speech/ssml/s_spec.rb +17 -13
- data/spec/ruby_speech/ssml/say_as_spec.rb +11 -7
- data/spec/ruby_speech/ssml/speak_spec.rb +48 -32
- data/spec/ruby_speech/ssml/sub_spec.rb +9 -5
- data/spec/ruby_speech/ssml/voice_spec.rb +23 -19
- data/spec/ruby_speech/ssml_spec.rb +64 -63
- data/spec/spec_helper.rb +0 -3
- metadata +10 -31
- data/lib/ruby_speech/xml.rb +0 -11
@@ -3,6 +3,10 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module GRXML
|
5
5
|
describe Tag do
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { described_class.new doc }
|
9
|
+
|
6
10
|
its(:name) { should == 'tag' }
|
7
11
|
|
8
12
|
it 'registers itself' do
|
@@ -21,12 +25,12 @@ module RubySpeech
|
|
21
25
|
|
22
26
|
describe "comparing objects" do
|
23
27
|
it "should be equal if the content is the same" do
|
24
|
-
Tag.new(:content => "hello").should == Tag.new(:content => "hello")
|
28
|
+
Tag.new(doc, :content => "hello").should == Tag.new(doc, :content => "hello")
|
25
29
|
end
|
26
30
|
|
27
31
|
describe "when the content is different" do
|
28
32
|
it "should not be equal" do
|
29
|
-
Tag.new(:content => "Hello").should_not == Tag.new(:content => "Hello there")
|
33
|
+
Tag.new(doc, :content => "Hello").should_not == Tag.new(doc, :content => "Hello there")
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
@@ -3,6 +3,10 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module GRXML
|
5
5
|
describe Token do
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { described_class.new doc }
|
9
|
+
|
6
10
|
its(:name) { should == 'token' }
|
7
11
|
|
8
12
|
it 'registers itself' do
|
@@ -37,12 +41,12 @@ module RubySpeech
|
|
37
41
|
|
38
42
|
describe "comparing objects" do
|
39
43
|
it "should be equal if the content is the same" do
|
40
|
-
Token.new(:content => "hello").should == Token.new(:content => "hello")
|
44
|
+
Token.new(doc, :content => "hello").should == Token.new(doc, :content => "hello")
|
41
45
|
end
|
42
46
|
|
43
47
|
describe "when the content is different" do
|
44
48
|
it "should not be equal" do
|
45
|
-
Token.new(:content => "Hello").should_not == Token.new(:content => "Hello there")
|
49
|
+
Token.new(doc, :content => "Hello").should_not == Token.new(doc, :content => "Hello there")
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
@@ -3,8 +3,11 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
describe GRXML do
|
5
5
|
describe "#draw" do
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
6
8
|
it "should create a GRXML document" do
|
7
|
-
GRXML.draw.should == GRXML::Grammar.new
|
9
|
+
GRXML.draw.should == GRXML::Grammar.new(doc)
|
10
|
+
GRXML.draw.document.xpath('ns:grammar', ns: 'http://www.w3.org/2001/06/grammar').size.should == 1
|
8
11
|
end
|
9
12
|
|
10
13
|
context "with a root rule name specified but not found" do
|
@@ -15,25 +18,25 @@ module RubySpeech
|
|
15
18
|
'6'
|
16
19
|
end
|
17
20
|
end
|
18
|
-
end.should raise_error(InvalidChildError, "A GRXML document must have a rule matching the root rule name")
|
21
|
+
end.should raise_error(GRXML::InvalidChildError, "A GRXML document must have a rule matching the root rule name")
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
25
|
# TODO: Maybe GRXML#draw should create a Rule to pass the string
|
23
26
|
describe "when the return value of the block is a string" do
|
24
27
|
it "should be inserted into the document" do
|
25
|
-
lambda { GRXML.draw { "Hello Fred" }}.should raise_error(InvalidChildError, "A Grammar can only accept Rule and Tag as children")
|
28
|
+
lambda { GRXML.draw { "Hello Fred" }}.should raise_error(GRXML::InvalidChildError, "A Grammar can only accept Rule and Tag as children")
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
29
32
|
it "should allow other GRXML elements to be inserted in the document" do
|
30
|
-
|
33
|
+
drawn_doc = GRXML.draw(:mode => :voice, :root => 'main') { rule :id => :main, :content => "Hello Fred" }
|
31
34
|
|
32
|
-
expected_doc = GRXML::Grammar.new(:mode => :voice, :root => 'main')
|
33
|
-
rule = GRXML::Rule.new(:id => "main")
|
35
|
+
expected_doc = GRXML::Grammar.new(doc, :mode => :voice, :root => 'main')
|
36
|
+
rule = GRXML::Rule.new(doc, :id => "main")
|
34
37
|
rule << "Hello Fred"
|
35
38
|
expected_doc << rule
|
36
|
-
|
39
|
+
drawn_doc.should == expected_doc
|
37
40
|
end
|
38
41
|
|
39
42
|
it "should allow accessing methods defined outside the block" do
|
@@ -41,14 +44,14 @@ module RubySpeech
|
|
41
44
|
'bar'
|
42
45
|
end
|
43
46
|
|
44
|
-
|
47
|
+
drawn_doc = GRXML.draw do
|
45
48
|
rule :id => foo
|
46
49
|
end
|
47
50
|
|
48
|
-
expected_doc = GRXML::Grammar.new
|
49
|
-
rule = GRXML::Rule.new(:id => foo)
|
51
|
+
expected_doc = GRXML::Grammar.new doc
|
52
|
+
rule = GRXML::Rule.new(doc, :id => foo)
|
50
53
|
expected_doc << rule
|
51
|
-
|
54
|
+
drawn_doc.should == expected_doc
|
52
55
|
end
|
53
56
|
|
54
57
|
it "should raise error if given an empty rule" do
|
@@ -57,18 +60,18 @@ module RubySpeech
|
|
57
60
|
end
|
58
61
|
|
59
62
|
it "should allow nested block return values" do
|
60
|
-
|
63
|
+
drawn_doc = RubySpeech::GRXML.draw do
|
61
64
|
rule :scope => 'public', :id => :main do
|
62
65
|
"Hello Fred"
|
63
66
|
end
|
64
67
|
end
|
65
|
-
expected_doc = GRXML::Grammar.new
|
66
|
-
expected_doc << GRXML::Rule.new(:scope => :public, :id => :main, :content => "Hello Fred")
|
67
|
-
|
68
|
+
expected_doc = GRXML::Grammar.new doc
|
69
|
+
expected_doc << GRXML::Rule.new(doc, :scope => :public, :id => :main, :content => "Hello Fred")
|
70
|
+
drawn_doc.should == expected_doc
|
68
71
|
end
|
69
72
|
|
70
73
|
it "should allow nested GRXML elements" do
|
71
|
-
|
74
|
+
drawn_doc = RubySpeech::GRXML.draw do
|
72
75
|
rule :id => :main, :scope => 'public' do
|
73
76
|
string "Hello Fred. I like ninjas and pirates"
|
74
77
|
one_of do
|
@@ -77,14 +80,14 @@ module RubySpeech
|
|
77
80
|
end
|
78
81
|
end
|
79
82
|
end
|
80
|
-
rule = GRXML::Rule.new(:id => :main, :scope => 'public', :content => "Hello Fred. I like ninjas and pirates")
|
81
|
-
oneof = GRXML::OneOf.new
|
82
|
-
oneof << GRXML::Item.new(:content => "ninja")
|
83
|
-
oneof << GRXML::Item.new(:content => "pirate")
|
83
|
+
rule = GRXML::Rule.new(doc, :id => :main, :scope => 'public', :content => "Hello Fred. I like ninjas and pirates")
|
84
|
+
oneof = GRXML::OneOf.new doc
|
85
|
+
oneof << GRXML::Item.new(doc, :content => "ninja")
|
86
|
+
oneof << GRXML::Item.new(doc, :content => "pirate")
|
84
87
|
rule << oneof
|
85
|
-
expected_doc = GRXML::Grammar.new
|
88
|
+
expected_doc = GRXML::Grammar.new doc
|
86
89
|
expected_doc << rule
|
87
|
-
|
90
|
+
drawn_doc.should == expected_doc
|
88
91
|
end
|
89
92
|
|
90
93
|
# TODO: maybe turn a rule embedded in anthoer rule into a ruleref??
|
@@ -143,13 +146,13 @@ module RubySpeech
|
|
143
146
|
end
|
144
147
|
|
145
148
|
it "should raise an exception" do
|
146
|
-
lambda { voice_doc }.should raise_error(InvalidChildError, "Embedded grammars must have the same mode")
|
149
|
+
lambda { voice_doc }.should raise_error(GRXML::InvalidChildError, "Embedded grammars must have the same mode")
|
147
150
|
end
|
148
151
|
end
|
149
152
|
end
|
150
153
|
|
151
154
|
it "GRXML elements" do
|
152
|
-
element = GRXML::Item.new :content => "HELLO?"
|
155
|
+
element = GRXML::Item.new doc, :content => "HELLO?"
|
153
156
|
|
154
157
|
doc = RubySpeech::GRXML.draw do
|
155
158
|
rule :id => :main, :scope => 'public' do
|
@@ -188,23 +191,23 @@ module RubySpeech
|
|
188
191
|
end
|
189
192
|
|
190
193
|
it "should properly escape string input" do
|
191
|
-
|
194
|
+
drawn_doc = RubySpeech::GRXML.draw do
|
192
195
|
rule { string "I <3 nachos." }
|
193
196
|
rule { "I <3 nachos." }
|
194
197
|
rule { 'I <3 nachos.' }
|
195
198
|
end
|
196
|
-
expected_doc = GRXML::Grammar.new
|
199
|
+
expected_doc = GRXML::Grammar.new doc
|
197
200
|
3.times do
|
198
|
-
expected_doc << GRXML::Rule.new(:native_content => "I <3 nachos.")
|
201
|
+
expected_doc << GRXML::Rule.new(doc, :native_content => "I <3 nachos.")
|
199
202
|
end
|
200
|
-
|
203
|
+
drawn_doc.should == expected_doc
|
201
204
|
end
|
202
205
|
|
203
206
|
# TODO: verfify rule is in document if named in a ruleref
|
204
207
|
# TODO: ruleref must have named rule id
|
205
208
|
|
206
209
|
it "should allow all permutations of possible nested GRXML elements" do
|
207
|
-
|
210
|
+
drawn_doc = RubySpeech::GRXML.draw do
|
208
211
|
rule :id => "hello" do
|
209
212
|
string "HELLO?"
|
210
213
|
item :weight => 2.5
|
@@ -229,43 +232,44 @@ module RubySpeech
|
|
229
232
|
one_of { item { "single item" } }
|
230
233
|
end
|
231
234
|
end
|
232
|
-
expected_doc = GRXML::Grammar.new
|
233
|
-
rule = GRXML::Rule.new(:id => "hello", :content => "HELLO?")
|
234
|
-
rule << GRXML::Item.new(:weight => 2.5)
|
235
|
-
oneof = GRXML::OneOf.new
|
236
|
-
1.upto(2) { |d| oneof << GRXML::Item.new(:content => d.to_s) }
|
235
|
+
expected_doc = GRXML::Grammar.new doc
|
236
|
+
rule = GRXML::Rule.new(doc, :id => "hello", :content => "HELLO?")
|
237
|
+
rule << GRXML::Item.new(doc, :weight => 2.5)
|
238
|
+
oneof = GRXML::OneOf.new doc
|
239
|
+
1.upto(2) { |d| oneof << GRXML::Item.new(doc, :content => d.to_s) }
|
237
240
|
rule << oneof
|
238
|
-
rule << GRXML::Ruleref.new(:uri => '#test')
|
239
|
-
rule << GRXML::Item.new(:content => "last")
|
241
|
+
rule << GRXML::Ruleref.new(doc, :uri => '#test')
|
242
|
+
rule << GRXML::Item.new(doc, :content => "last")
|
240
243
|
expected_doc << rule
|
241
244
|
|
242
|
-
rule = GRXML::Rule.new(:id => "test", :content => "TESTING")
|
245
|
+
rule = GRXML::Rule.new(doc, :id => "test", :content => "TESTING")
|
243
246
|
expected_doc << rule
|
244
247
|
|
245
|
-
rule = GRXML::Rule.new(:id => "hello2")
|
246
|
-
rule << GRXML::Item.new(:weight => 5.5, :content => "hello")
|
248
|
+
rule = GRXML::Rule.new(doc, :id => "hello2")
|
249
|
+
rule << GRXML::Item.new(doc, :weight => 5.5, :content => "hello")
|
247
250
|
rule << "H...E...L...L...O?"
|
248
|
-
rule << GRXML::Token.new(:content => "test token")
|
249
|
-
rule << GRXML::Tag.new
|
250
|
-
rule << GRXML::Item.new
|
251
|
-
oneof = GRXML::OneOf.new
|
252
|
-
oneof << GRXML::Item.new(:content => "single item")
|
251
|
+
rule << GRXML::Token.new(doc, :content => "test token")
|
252
|
+
rule << GRXML::Tag.new(doc)
|
253
|
+
rule << GRXML::Item.new(doc)
|
254
|
+
oneof = GRXML::OneOf.new doc
|
255
|
+
oneof << GRXML::Item.new(doc, :content => "single item")
|
253
256
|
rule << oneof
|
254
257
|
expected_doc << rule
|
255
|
-
|
258
|
+
drawn_doc.should == expected_doc
|
256
259
|
end
|
257
260
|
|
258
261
|
describe "importing nested tags" do
|
259
|
-
let(:
|
262
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
263
|
+
let(:item) { GRXML::Item.new(doc, :weight => 1.5, :content => "Are you a pirate or ninja?") }
|
260
264
|
let(:string) { "Hello Fred. I like pirates and ninjas " }
|
261
265
|
let :rule do
|
262
|
-
GRXML::Rule.new(:id => :main, :scope => 'public', :content => string).tap do |rule|
|
266
|
+
GRXML::Rule.new(doc, :id => :main, :scope => 'public', :content => string).tap do |rule|
|
263
267
|
rule << item
|
264
268
|
end
|
265
269
|
end
|
266
270
|
|
267
271
|
let :document do
|
268
|
-
GRXML::Grammar.new.tap { |doc| doc << rule }.to_s
|
272
|
+
GRXML::Grammar.new(doc).tap { |doc| doc << rule }.to_s
|
269
273
|
end
|
270
274
|
|
271
275
|
let(:import) { GRXML.import document }
|
@@ -287,14 +291,14 @@ module RubySpeech
|
|
287
291
|
end
|
288
292
|
|
289
293
|
it "should allow finding direct children of a particular type, matching certain attributes" do
|
290
|
-
item = GRXML::Item.new
|
291
|
-
item1 = GRXML::Item.new :weight => 0.5
|
292
|
-
item11 = GRXML::Item.new :weight => 0.5
|
294
|
+
item = GRXML::Item.new doc
|
295
|
+
item1 = GRXML::Item.new doc, :weight => 0.5
|
296
|
+
item11 = GRXML::Item.new doc, :weight => 0.5
|
293
297
|
item1 << item11
|
294
298
|
item << item1
|
295
|
-
item2 = GRXML::Item.new :weight => 0.7
|
299
|
+
item2 = GRXML::Item.new doc, :weight => 0.7
|
296
300
|
item << item2
|
297
|
-
tag = GRXML::Tag.new
|
301
|
+
tag = GRXML::Tag.new doc
|
298
302
|
item << tag
|
299
303
|
|
300
304
|
item.children(:item, :weight => 0.5).should == [item1]
|
@@ -318,22 +322,6 @@ module RubySpeech
|
|
318
322
|
text = item.nokogiri_children.first
|
319
323
|
text.parent.should == item
|
320
324
|
end
|
321
|
-
end # draw
|
322
|
-
|
323
|
-
describe "manually created documents" do
|
324
|
-
it "should be able to traverse up the tree" do
|
325
|
-
grammar = GRXML::Grammar.new
|
326
|
-
rule = GRXML::Rule.new :id => 'one'
|
327
|
-
item = GRXML::Item.new
|
328
|
-
text = Nokogiri::XML::Text.new 'foobar', grammar.document
|
329
|
-
item << text
|
330
|
-
rule << item
|
331
|
-
grammar << rule
|
332
|
-
|
333
|
-
text.parent.should == item
|
334
|
-
item.parent.should == rule
|
335
|
-
rule.parent.should == grammar
|
336
|
-
end
|
337
325
|
end
|
338
326
|
end # GRXML
|
339
327
|
end # RubySpeech
|
@@ -3,10 +3,14 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module SSML
|
5
5
|
describe Audio do
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { described_class.new doc }
|
9
|
+
|
6
10
|
its(:name) { should == 'audio' }
|
7
11
|
|
8
12
|
describe "setting options in initializers" do
|
9
|
-
subject { Audio.new :src => 'http://whatever.you-say-boss.com', :content => 'Hello' }
|
13
|
+
subject { Audio.new doc, :src => 'http://whatever.you-say-boss.com', :content => 'Hello' }
|
10
14
|
|
11
15
|
its(:src) { should == 'http://whatever.you-say-boss.com' }
|
12
16
|
its(:content) { should == 'Hello' }
|
@@ -47,51 +51,51 @@ module RubySpeech
|
|
47
51
|
end
|
48
52
|
|
49
53
|
it "should accept Audio" do
|
50
|
-
lambda { subject << Audio.new }.should_not raise_error
|
54
|
+
lambda { subject << Audio.new(doc) }.should_not raise_error
|
51
55
|
end
|
52
56
|
|
53
57
|
it "should accept Break" do
|
54
|
-
lambda { subject << Break.new }.should_not raise_error
|
58
|
+
lambda { subject << Break.new(doc) }.should_not raise_error
|
55
59
|
end
|
56
60
|
|
57
61
|
it "should accept Desc" do
|
58
|
-
lambda { subject << Desc.new }.should_not raise_error
|
62
|
+
lambda { subject << Desc.new(doc) }.should_not raise_error
|
59
63
|
end
|
60
64
|
|
61
65
|
it "should accept Emphasis" do
|
62
|
-
lambda { subject << Emphasis.new }.should_not raise_error
|
66
|
+
lambda { subject << Emphasis.new(doc) }.should_not raise_error
|
63
67
|
end
|
64
68
|
|
65
69
|
it "should accept Mark" do
|
66
|
-
lambda { subject << Mark.new }.should_not raise_error
|
70
|
+
lambda { subject << Mark.new(doc) }.should_not raise_error
|
67
71
|
end
|
68
72
|
|
69
73
|
it "should accept P" do
|
70
|
-
lambda { subject << P.new }.should_not raise_error
|
74
|
+
lambda { subject << P.new(doc) }.should_not raise_error
|
71
75
|
end
|
72
76
|
|
73
77
|
it "should accept Phoneme" do
|
74
|
-
lambda { subject << Phoneme.new }.should_not raise_error
|
78
|
+
lambda { subject << Phoneme.new(doc) }.should_not raise_error
|
75
79
|
end
|
76
80
|
|
77
81
|
it "should accept Prosody" do
|
78
|
-
lambda { subject << Prosody.new }.should_not raise_error
|
82
|
+
lambda { subject << Prosody.new(doc) }.should_not raise_error
|
79
83
|
end
|
80
84
|
|
81
85
|
it "should accept SayAs" do
|
82
|
-
lambda { subject << SayAs.new(:interpret_as => :foo) }.should_not raise_error
|
86
|
+
lambda { subject << SayAs.new(doc, :interpret_as => :foo) }.should_not raise_error
|
83
87
|
end
|
84
88
|
|
85
89
|
it "should accept Sub" do
|
86
|
-
lambda { subject << Sub.new }.should_not raise_error
|
90
|
+
lambda { subject << Sub.new(doc) }.should_not raise_error
|
87
91
|
end
|
88
92
|
|
89
93
|
it "should accept S" do
|
90
|
-
lambda { subject << S.new }.should_not raise_error
|
94
|
+
lambda { subject << S.new(doc) }.should_not raise_error
|
91
95
|
end
|
92
96
|
|
93
97
|
it "should accept Voice" do
|
94
|
-
lambda { subject << Voice.new }.should_not raise_error
|
98
|
+
lambda { subject << Voice.new(doc) }.should_not raise_error
|
95
99
|
end
|
96
100
|
|
97
101
|
it "should raise InvalidChildError with non-acceptable objects" do
|
@@ -101,18 +105,18 @@ module RubySpeech
|
|
101
105
|
|
102
106
|
describe "comparing objects" do
|
103
107
|
it "should be equal if the content, and src are the same" do
|
104
|
-
Audio.new(:src => "one", :content => "Hello there").should == Audio.new(:src => "one", :content => "Hello there")
|
108
|
+
Audio.new(doc, :src => "one", :content => "Hello there").should == Audio.new(doc, :src => "one", :content => "Hello there")
|
105
109
|
end
|
106
110
|
|
107
111
|
describe "when the content is different" do
|
108
112
|
it "should not be equal" do
|
109
|
-
Audio.new(:content => "Hello").should_not == Audio.new(:content => "Hello there")
|
113
|
+
Audio.new(doc, :content => "Hello").should_not == Audio.new(doc, :content => "Hello there")
|
110
114
|
end
|
111
115
|
end
|
112
116
|
|
113
117
|
describe "when the src is different" do
|
114
118
|
it "should not be equal" do
|
115
|
-
Audio.new(:src => 'one').should_not == Audio.new(:src => 'two')
|
119
|
+
Audio.new(doc, :src => 'one').should_not == Audio.new(doc, :src => 'two')
|
116
120
|
end
|
117
121
|
end
|
118
122
|
end
|
@@ -3,13 +3,17 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module SSML
|
5
5
|
describe Break do
|
6
|
+
let(:doc) { Nokogiri::XML::Document.new }
|
7
|
+
|
8
|
+
subject { described_class.new doc }
|
9
|
+
|
6
10
|
its(:name) { should == 'break' }
|
7
11
|
|
8
12
|
describe "setting options in initializers" do
|
9
|
-
subject { Break.new :strength => :strong, :time => 3
|
13
|
+
subject { Break.new doc, :strength => :strong, :time => 3 }
|
10
14
|
|
11
15
|
its(:strength) { should == :strong }
|
12
|
-
its(:time) { should == 3
|
16
|
+
its(:time) { should == 3 }
|
13
17
|
end
|
14
18
|
|
15
19
|
it 'registers itself' do
|
@@ -24,7 +28,7 @@ module RubySpeech
|
|
24
28
|
it { should be_instance_of Break }
|
25
29
|
|
26
30
|
its(:strength) { should == :strong }
|
27
|
-
its(:time) { should == 3
|
31
|
+
its(:time) { should == 3 }
|
28
32
|
end
|
29
33
|
|
30
34
|
describe "#strength" do
|
@@ -48,14 +52,14 @@ module RubySpeech
|
|
48
52
|
|
49
53
|
describe "#time" do
|
50
54
|
context "with a valid value" do
|
51
|
-
before { subject.time = 3
|
55
|
+
before { subject.time = 3 }
|
52
56
|
|
53
|
-
its(:time) { should == 3
|
57
|
+
its(:time) { should == 3 }
|
54
58
|
end
|
55
59
|
|
56
60
|
context "with a negative value" do
|
57
61
|
it do
|
58
|
-
lambda { subject.time = -3
|
62
|
+
lambda { subject.time = -3 }.should raise_error(ArgumentError, "You must specify a valid time (positive float value in seconds)")
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
@@ -74,24 +78,24 @@ module RubySpeech
|
|
74
78
|
|
75
79
|
describe "comparing objects" do
|
76
80
|
it "should be equal if the content, strength and base uri are the same" do
|
77
|
-
Break.new(:strength => :strong, :time => 1
|
81
|
+
Break.new(doc, :strength => :strong, :time => 1, :content => "Hello there").should == Break.new(doc, :strength => :strong, :time => 1, :content => "Hello there")
|
78
82
|
end
|
79
83
|
|
80
84
|
describe "when the content is different" do
|
81
85
|
it "should not be equal" do
|
82
|
-
Break.new(:content => "Hello").should_not == Break.new(:content => "Hello there")
|
86
|
+
Break.new(doc, :content => "Hello").should_not == Break.new(doc, :content => "Hello there")
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
86
90
|
describe "when the strength is different" do
|
87
91
|
it "should not be equal" do
|
88
|
-
Break.new(:strength => :strong).should_not == Break.new(:strength => :weak)
|
92
|
+
Break.new(doc, :strength => :strong).should_not == Break.new(doc, :strength => :weak)
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
92
96
|
describe "when the time is different" do
|
93
97
|
it "should not be equal" do
|
94
|
-
Break.new(:time => 1
|
98
|
+
Break.new(doc, :time => 1).should_not == Break.new(doc, :time => 2)
|
95
99
|
end
|
96
100
|
end
|
97
101
|
end
|