spec/punchblock/component/output_spec.rb in punchblock-2.5.3 vs spec/punchblock/component/output_spec.rb in punchblock-2.6.0

- old
+ new

@@ -70,11 +70,12 @@ :repeat_interval => 2000, :repeat_times => 10, :max_time => 30000, :voice => 'allison', :renderer => 'swift', - :render_document => {:value => ssml_doc} + :render_document => {:value => ssml_doc}, + :headers => { 'Jump-Size' => '2', 'Kill-On-Barge-In' => 'false' } end describe '#interrupt_on' do subject { super().interrupt_on } it { should be == :voice } @@ -183,10 +184,15 @@ subject { super().render_documents } it { should == [] } end end + describe '#headers' do + subject { super().headers } + it { should be == { 'Jump-Size' => '2', 'Kill-On-Barge-In' => 'false' } } + end + describe "exporting to Rayo" do it "should export to XML that can be understood by its parser" do new_instance = RayoNode.from_xml Nokogiri::XML(subject.to_rayo.to_xml, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).root expect(new_instance).to be_instance_of described_class expect(new_instance.interrupt_on).to eq(:voice) @@ -196,10 +202,11 @@ expect(new_instance.repeat_times).to eq(10) expect(new_instance.max_time).to eq(30000) expect(new_instance.voice).to eq('allison') expect(new_instance.renderer).to eq('swift') expect(new_instance.render_documents).to eq([Output::Document.new(:value => ssml_doc)]) + expect(new_instance.headers).to eq({ 'Jump-Size' => '2', 'Kill-On-Barge-In' => 'false' }) end it "should wrap the document value in CDATA" do grammar_node = subject.to_rayo.at_xpath('ns:document', ns: described_class.registered_ns) expect(grammar_node.children.first).to be_a Nokogiri::XML::CDATA @@ -256,10 +263,12 @@ xml:lang="en-US"> <say-as interpret-as="ordinal">100</say-as> </speak> ]]> </document> + <header xmlns='urn:xmpp:rayo:1' name="Jump-Size" value="2" /> + <header xmlns='urn:xmpp:rayo:1' name="Kill-On-Barge-In" value="false" /> </output> MESSAGE end subject { RayoNode.from_xml parse_stanza(stanza).root, '9f00061', '1' } @@ -327,9 +336,14 @@ describe '#render_documents' do subject { super().render_documents } it { should be == [Output::Document.new(content_type: 'text/uri-list', value: ['http://example.com/hello.mp3', 'http://example.com/goodbye.mp3'])] } end + end + + describe '#headers' do + subject { super().headers } + it { should be == { 'Jump-Size' => '2', 'Kill-On-Barge-In' => 'false' } } end end describe Output::Document do describe "when not passing a content type" do