Sha256: b342a088c46846deac503614e4c57c47bb8fc1c6f0a68b278a6163bbbd1fda59

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
require 'nokogiri'

describe "Namespace cleaning" do

  it "should remove unnecessary namespaces" do
    stix = org.mitre.stix.core.STIXType.new
    stix.indicators = org.mitre.stix.core.IndicatorsType.new
    stix.indicators.add_indicator(org.mitre.stix.indicator.IndicatorType.new)
    doc = Nokogiri::XML(stix.to_xml)

    doc.root.namespaces.should == {
      "xmlns:indicator" => "http://stix.mitre.org/Indicator-2",
      "xmlns:stix" => "http://stix.mitre.org/stix-1",
      "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance"
    }
  end

  it "should not remove the ID namespace prefix" do
    StixRuby.set_id_namespace("example.com", "example")
    stix = org.mitre.stix.core.STIXType.new
    stix.indicators = org.mitre.stix.core.IndicatorsType.new
    stix.indicators.add_indicator(org.mitre.stix.indicator.IndicatorType.new)

    doc = Nokogiri::XML(stix.to_xml)

    doc.root.namespaces.should == {
      "xmlns:indicator" => "http://stix.mitre.org/Indicator-2",
      "xmlns:stix" => "http://stix.mitre.org/stix-1",
      "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
      "xmlns:example" => "example.com"
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_stix-0.2.0-java spec/units/namespace_cleaner_spec.rb
ruby_stix-0.0.2-java spec/units/namespace_cleaner_spec.rb