require 'spec_helper' module RubySpeech describe SSML do describe "#draw" do it "should create an SSML document" do expected_doc = SSML::Speak.new 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" }.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 }.to_s.should == expected_doc.to_s end end it "should allow other SSML elements to be inserted in the document" do doc = SSML.draw { voice gender: :male, name: 'fred' } expected_doc = SSML::Speak.new expected_doc << SSML::Voice.new(gender: :male, name: 'fred') doc.to_s.should == expected_doc.to_s end it "should allow nested block return values" do doc = RubySpeech::SSML.draw do voice gender: :male, name: 'fred' do "Hi, I'm Fred." end end expected_doc = SSML::Speak.new expected_doc <