diff --git a/lib/multi_xml.rb b/lib/multi_xml.rb index ad97a75..062a7de 100644 --- a/lib/multi_xml.rb +++ b/lib/multi_xml.rb @@ -57,7 +57,7 @@ class ParseError < StandardError; end class << self # Get the current parser class. def parser - return @@parser if defined?(@@parser) + return @@parser unless @@parser.nil? self.parser = self.default_parser @@parser end diff --git a/spec/multi_xml_spec.rb b/spec/multi_xml_spec.rb index 782325c..195bdc1 100644 --- a/spec/multi_xml_spec.rb +++ b/spec/multi_xml_spec.rb @@ -5,6 +5,10 @@ class MockDecoder; end describe "MultiXml" do context "Parsers" do + before do + MultiXml.send :class_variable_set, :@@parser, nil + end + it "should pick a default parser" do MultiXml.parser.should be_kind_of(Module) MultiXml.parser.should respond_to(:parse)