Skip to content

Commit

Permalink
SSML.draw should return a Nokogiri XML document rather than a string
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Jul 7, 2011
1 parent 25c3895 commit 7694afb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/ruby_speech/ssml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.draw(&block)
block_return = speak.instance_eval(&block) if block_given?
speak << block_return if block_return.is_a?(String)
end
end.to_s
end
end
end # SSML
end # RubySpeech
14 changes: 7 additions & 7 deletions spec/ruby_speech/ssml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ module RubySpeech

it "should create an SSML document" do
expected_doc << SSML::Speak.new
SSML.draw.should == expected_doc.to_s
SSML.draw.to_s.should == expected_doc.to_s
end

describe "when the return value of the block is a string" do
it "should be inserted into the document" do
expected_doc << SSML::Speak.new(content: "Hi, I'm Fred")
SSML.draw { "Hi, I'm Fred" }.should == expected_doc.to_s
SSML.draw { "Hi, I'm Fred" }.to_s.should == expected_doc.to_s
end
end

describe "when the return value of the block is a string" do
it "should not be inserted into the document" do
expected_doc << SSML::Speak.new
SSML.draw { :foo }.should == expected_doc.to_s
SSML.draw { :foo }.to_s.should == expected_doc.to_s
end
end

Expand All @@ -29,7 +29,7 @@ module RubySpeech
speak = SSML::Speak.new
speak << SSML::Voice.new(gender: :male, name: 'fred')
expected_doc << speak
doc.should == expected_doc.to_s
doc.to_s.should == expected_doc.to_s
end

it "should allow nested block return values" do
Expand All @@ -41,7 +41,7 @@ module RubySpeech
speak = SSML::Speak.new
speak << SSML::Voice.new(gender: :male, name: 'fred', content: "Hi, I'm Fred.")
expected_doc << speak
doc.should == expected_doc.to_s
doc.to_s.should == expected_doc.to_s
end

it "should allow nested SSML elements" do
Expand All @@ -58,7 +58,7 @@ module RubySpeech
voice << SSML::SayAs.new('date', format: 'dmy', content: "01/02/1960")
speak << voice
expected_doc << speak
doc.should == expected_doc.to_s
doc.to_s.should == expected_doc.to_s
end

it "should allow all permutations of possible nested SSML elements" do
Expand Down Expand Up @@ -126,7 +126,7 @@ module RubySpeech
voice << SSML::Voice.new(age: 12, content: "And I'm young Fred")
speak << voice
expected_doc << speak
doc.should == expected_doc.to_s
doc.to_s.should == expected_doc.to_s
end
end
end
Expand Down

0 comments on commit 7694afb

Please sign in to comment.