Skip to content

Commit

Permalink
[CS] Feed the CI hound
Browse files Browse the repository at this point in the history
  • Loading branch information
sfgeorge committed Jan 7, 2017
1 parent 52f4c9b commit 6555d82
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
7 changes: 5 additions & 2 deletions lib/ruby_speech/grxml/grammar.rb
Expand Up @@ -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
Expand Down
75 changes: 38 additions & 37 deletions spec/ruby_speech/grxml/grammar_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6555d82

Please sign in to comment.