Sha256: 5f7a352c90b1b0fee7dcbb893b7fee30d14deab1d2aa321636474dbb0e587da9

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

module Stash
  module Sword
    describe Namespace do

      it 'defines namespaces' do
        by_namespace = {}
        by_uri = {}
        by_prefix = {}

        Namespace.each do |ns_enum|
          expect(ns_enum.value).to be_an(XML::MappingExtensions::Namespace)

          expect(by_namespace.key?(ns_enum.value)).to be(false), -> { "Duplicate namespace: #{by_namespace[ns_enum.value].key} and #{ns_enum.key} both declare #{ns_enum.value}" }
          by_namespace[ns_enum.value] = ns_enum

          expect(by_uri.key?(ns_enum.uri)).to be(false), -> { "Duplicate URI: #{by_uri[ns_enum.uri].key} and #{ns_enum.key} both declare #{ns_enum.uri}" }
          by_uri[ns_enum.uri] = ns_enum

          if ns_enum.prefix
            expect(by_prefix.key?(ns_enum.prefix)).to be(false), -> { "Duplicate prefix: #{by_prefix[ns_enum.prefix].key} and #{ns_enum.key} both declare #{ns_enum.prefix}" }
            by_prefix[ns_enum.prefix] = ns_enum
          end
        end

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stash-sword-0.1.6 spec/unit/stash/sword2/namespaces_spec.rb
stash-sword-0.1.5 spec/unit/stash/sword2/namespaces_spec.rb
stash-sword-0.1.4 spec/unit/stash/sword2/namespaces_spec.rb
stash-sword-0.1.3 spec/unit/stash/sword2/namespaces_spec.rb
stash-sword-0.1.2 spec/unit/stash/sword2/namespaces_spec.rb
stash-sword-0.1.1 spec/unit/stash/sword2/namespaces_spec.rb
stash-sword-0.1.0 spec/unit/stash/sword2/namespaces_spec.rb