From b562bed265918b43ac1c4c638ae3a7ffe95ecd83 Mon Sep 17 00:00:00 2001 From: Sebastian Staudt Date: Tue, 17 Apr 2012 10:17:30 +0200 Subject: [PATCH] Reset @@parser in between specs This fixes specs on JRuby. --- lib/multi_xml.rb | 2 +- spec/multi_xml_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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)