Sha256: b18178b2c452a2319edb1fc9cdd085ec8917fda47525557a93a7242be259da36

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'spec/spec_helper.rb'

describe ROXML, "#xml_namespaces" do
  describe "for reading" do
    class Tires
       include ROXML

       xml_namespaces \
         :bobsbike => 'http://bobsbikes.example.com',
         :alicesauto => 'http://alicesautosupply.example.com/'

       xml_reader :bike_tires, :as => [], :from => '@name', :in => 'bobsbike:tire'
       xml_reader :car_tires, :as => [], :from => '@name', :in => 'alicesauto:tire'
     end

    before do
       @xml = %{<?xml version="1.0"?>
         <inventory xmlns="http://alicesautosupply.example.com/" xmlns:bike="http://bobsbikes.example.com">
          <tire name="super slick racing tire" />
          <tire name="all weather tire" />
          <bike:tire name="skinny street" />
         </inventory>
       }
    end
  
    it "should remap default namespaces" do
      Tires.from_xml(@xml).car_tires.should =~ ['super slick racing tire', 'all weather tire']
    end

    it "should remap prefix namespaces" do
      Tires.from_xml(@xml).bike_tires.should == ['skinny street']
    end
  end

  context "when an included namespace is not defined in the xml" do
    context "where the missing namespace is the default" do
      it "should raise"

      context "but the namespace is declared in the body" do
        it "should succeed"
      end
    end
    
    context "where the missing namespace is included in a namespacey from" do
      it "should raise"

      context "but the namespace is declared in the body" do
        it "should succeed"
      end
    end
    
    context "where the missing namespace is included in an explicit :namespace" do
      it "should raise"

      context "but the namespace is declared in the body" do
        it "should succeed"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roxml-3.1.2 spec/xml/namespaces_spec.rb