Permalink
Browse files

[FEATURE] Allow comparison of parsed NLSML documents

  • Loading branch information...
1 parent 48efa3a commit f92558f0bee6e01171b53d9efafa60ca30091e11 @benlangfeld committed Oct 11, 2012
Showing with 17 additions and 1 deletion.
  1. +9 −1 lib/ruby_speech/nlsml/document.rb
  2. +8 −0 spec/ruby_speech/nlsml_spec.rb
View
10 lib/ruby_speech/nlsml/document.rb
@@ -23,6 +23,14 @@ def match?
interpretation_nodes.count > 0
end
+ def ==(other)
+ xml.to_xml == other.xml.to_xml
+ end
+
+ protected
+
+ attr_accessor :xml
+
private
def input_hash_for_interpretation(interpretation)
@@ -64,7 +72,7 @@ def interpretation_hash_for_interpretation(interpretation)
end
def result
- @xml.root
+ xml.root
end
def interpretation_nodes
View
8 spec/ruby_speech/nlsml_spec.rb
@@ -109,6 +109,14 @@
its(:interpretations) { should == expected_interpretations }
its(:best_interpretation) { should == expected_best_interpretation }
+ it "should be equal if the XML is the same" do
+ subject.should be == RubySpeech.parse(example_document)
+ end
+
+ it "should not be equal if the XML is different" do
+ subject.should_not be == RubySpeech.parse('<result xmlns:xf="http://www.w3.org/2000/xforms" grammar="http://flight"/>')
+ end
+
context "without any interpretations" do
let :doc_without_interpretations do
'''

0 comments on commit f92558f

Please sign in to comment.