Skip to content

Commit

Permalink
[BUGFIX] Drawing an NLSML doc should return something structured/parsed
Browse files Browse the repository at this point in the history
Fixes #22
  • Loading branch information
benlangfeld committed Mar 24, 2014
1 parent ad97d0e commit 539d2cc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# [develop](https://github.com/benlangfeld/ruby_speech)
* Bugfix: String nodes should take non-strings and cast to a string (`#to_s`)
* Bugfix: Cleanly handle NLSML with no input tag
* Bugfix: Drawing an NLSML doc should return something structured/parsed

# [2.3.1](https://github.com/benlangfeld/ruby_speech/compare/v2.3.0...v2.3.1) - [2014-02-24](https://rubygems.org/gems/ruby_speech/versions/2.3.1)
* Bugfix: Phone number grammar should only allow a single instance of '*'/'x'
Expand Down
3 changes: 2 additions & 1 deletion lib/ruby_speech/nlsml/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ class Builder

def initialize(options = {}, &block)
options = {'xmlns' => NLSML_NAMESPACE}.merge(options)
@document = Nokogiri::XML::Builder.new do |builder|
xml_doc = Nokogiri::XML::Builder.new do |builder|
builder.result options do |r|
apply_block r, &block
end
end.doc
@document = RubySpeech::NLSML::Document.new xml_doc
end

def interpretation(*args, &block)
Expand Down
4 changes: 4 additions & 0 deletions lib/ruby_speech/nlsml/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def noinput?
noinput_elements.any?
end

def to_xml
document.to_xml
end

private

def nomatch?
Expand Down
16 changes: 16 additions & 0 deletions spec/ruby_speech/nlsml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@
document.to_xml.should == expected_document
end

it "should return a structured/parsed document" do
document = RubySpeech::NLSML.draw(grammar: 'http://flight') do
interpretation confidence: 0.6 do
input "I want to go to Pittsburgh", mode: :speech

instance do
airline do
to_city 'Pittsburgh'
end
end
end
end

document.should be_match
end

context "with a string instance" do
let :example_document do
'''
Expand Down

0 comments on commit 539d2cc

Please sign in to comment.