Sha256: b8a089f1177b5a9875f6951818c1e439cf216e593ae36a0decc9f2b2045aaf49

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'helper'
require 'parser_shared_example'

class MockDecoder; end

describe "MultiXml" do
  context "Parsers" do
    it "picks a default parser" do
      expect(MultiXml.parser).to be_kind_of(Module)
      expect(MultiXml.parser).to respond_to(:parse)
    end

    it "defaults to the best available gem" do
      pending
      expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Rexml')
      require 'nokogiri'
      expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Nokogiri')
      require 'libxml'
      expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Libxml')
    end

    it "is settable via a symbol" do
      MultiXml.parser = :nokogiri
      expect(MultiXml.parser.name).to eq('MultiXml::Parsers::Nokogiri')
    end

    it "is settable via a class" do
      MultiXml.parser = MockDecoder
      expect(MultiXml.parser.name).to eq('MockDecoder')
    end
  end

  [['LibXML', 'libxml'],
   ['REXML', 'rexml/document'],
   ['Nokogiri', 'nokogiri'],
   ['Ox', 'ox']].each do |parser|
    begin
      require parser.last
      context "#{parser.first} parser" do
        it_behaves_like "a parser", parser.first
      end
    rescue LoadError => e
      puts "Tests not run for #{parser.first} due to a LoadError"
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
multi_xml-0.5.4 spec/multi_xml_spec.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/multi_xml-0.5.3/spec/multi_xml_spec.rb
multi_xml-0.5.3 spec/multi_xml_spec.rb
multi_xml-0.5.2 spec/multi_xml_spec.rb