From 6555d82523703d980c3ba4575e32de719ddf333b Mon Sep 17 00:00:00 2001 From: Stephen George Date: Wed, 4 Jan 2017 10:44:35 -0600 Subject: [PATCH] [CS] Feed the CI hound --- lib/ruby_speech/grxml/grammar.rb | 7 ++- spec/ruby_speech/grxml/grammar_spec.rb | 75 +++++++++++++------------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/lib/ruby_speech/grxml/grammar.rb b/lib/ruby_speech/grxml/grammar.rb index 09133b4..80defde 100644 --- a/lib/ruby_speech/grxml/grammar.rb +++ b/lib/ruby_speech/grxml/grammar.rb @@ -118,9 +118,12 @@ def inline def inline! loop do rule = nil - xpath("//ns:ruleref", :ns => GRXML_NAMESPACE).each do |ref| + xpath("//ns:ruleref", ns: GRXML_NAMESPACE).each do |ref| rule = rule_with_id ref[:uri].sub(/^#/, '') - raise ArgumentError, "The Ruleref \"#{ref[:uri]}\" is referenced but not defined" unless rule + unless rule + raise ArgumentError, + "The Ruleref \"#{ref[:uri]}\" is referenced but not defined" + end ref.swap rule.dup.children end break unless rule diff --git a/spec/ruby_speech/grxml/grammar_spec.rb b/spec/ruby_speech/grxml/grammar_spec.rb index f6c9f26..2f57392 100644 --- a/spec/ruby_speech/grxml/grammar_spec.rb +++ b/spec/ruby_speech/grxml/grammar_spec.rb @@ -233,22 +233,22 @@ module GRXML grammar.should == inline_grammar end - context 'nested' do + context "nested" do let :expected_doc do - RubySpeech::GRXML.draw mode: :dtmf, root: 'main' do - rule :id => :main, :scope => 'public' do + RubySpeech::GRXML.draw mode: :dtmf, root: "main" do + rule id: :main, scope: "public" do string "How about an oatmeal cookie? You'll feel better." end end end - context '1 level deep' do + context "1 level deep" do subject do - RubySpeech::GRXML.draw mode: :dtmf, root: 'main' do - rule :id => :main, :scope => 'public' do - ruleref uri: '#rabbit_hole2' + RubySpeech::GRXML.draw mode: :dtmf, root: "main" do + rule id: :main, scope: "public" do + ruleref uri: "#rabbit_hole2" end - rule id: 'rabbit_hole2' do + rule id: "rabbit_hole2" do string "How about an oatmeal cookie? You'll feel better." end end.inline @@ -257,16 +257,16 @@ module GRXML it { should eq expected_doc } end - context '2 levels deep' do + context "2 levels deep" do subject do - RubySpeech::GRXML.draw mode: :dtmf, root: 'main' do - rule :id => :main, :scope => 'public' do - ruleref uri: '#rabbit_hole2' + RubySpeech::GRXML.draw mode: :dtmf, root: "main" do + rule id: :main, scope: "public" do + ruleref uri: "#rabbit_hole2" end - rule id: 'rabbit_hole2' do - ruleref uri: '#rabbit_hole3' + rule id: "rabbit_hole2" do + ruleref uri: "#rabbit_hole3" end - rule id: 'rabbit_hole3' do + rule id: "rabbit_hole3" do string "How about an oatmeal cookie? You'll feel better." end end.inline @@ -275,19 +275,19 @@ module GRXML it { should eq expected_doc } end - context '3 levels deep' do + context "3 levels deep" do subject do - RubySpeech::GRXML.draw mode: :dtmf, root: 'main' do - rule :id => :main, :scope => 'public' do - ruleref uri: '#rabbit_hole2' + RubySpeech::GRXML.draw mode: :dtmf, root: "main" do + rule id: :main, scope: "public" do + ruleref uri: "#rabbit_hole2" end - rule id: 'rabbit_hole2' do - ruleref uri: '#rabbit_hole3' + rule id: "rabbit_hole2" do + ruleref uri: "#rabbit_hole3" end - rule id: 'rabbit_hole3' do - ruleref uri: '#rabbit_hole4' + rule id: "rabbit_hole3" do + ruleref uri: "#rabbit_hole4" end - rule id: 'rabbit_hole4' do + rule id: "rabbit_hole4" do string "How about an oatmeal cookie? You'll feel better." end end.inline @@ -296,32 +296,33 @@ module GRXML it { should eq expected_doc } end - context 'in a self-referencial infinite loop' do + context "in a self-referencial infinite loop" do subject do - RubySpeech::GRXML.draw mode: :dtmf, root: 'main' do - rule :id => :main, :scope => 'public' do - ruleref uri: '#paradox' + RubySpeech::GRXML.draw mode: :dtmf, root: "main" do + rule id: :main, scope: "public" do + ruleref uri: "#paradox" end - rule id: 'paradox' do - ruleref uri: '#paradox' + rule id: "paradox" do + ruleref uri: "#paradox" end end.inline end - pending 'should raise an Exception' + pending "should raise an Exception" end - context 'with an invalid-reference' do + context "with an invalid-reference" do subject do - RubySpeech::GRXML.draw mode: :dtmf, root: 'main' do - rule :id => :main, :scope => 'public' do - ruleref uri: '#lost' + RubySpeech::GRXML.draw mode: :dtmf, root: "main" do + rule id: :main, scope: "public" do + ruleref uri: "#lost" end end.inline end - it 'should raise a descriptive exception' do - expect { subject }.to raise_error ArgumentError, 'The Ruleref "#lost" is referenced but not defined' + it "should raise a descriptive exception" do + expect { subject }.to raise_error ArgumentError, + 'The Ruleref "#lost" is referenced but not defined' end end end