Sha256: bd67bba6442a0d1eb456fe71a92c049496b6c82ebc6dcb8a2f3463b42cd3a56a

Contents?: true

Size: 1.58 KB

Versions: 9

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe( RCAP::CAP_1_1::Parameter ) do
  context( 'when initialised' ) do
    context( 'from XML' ) do
      before( :each ) do

        @alert = RCAP::CAP_1_1::Alert.new do |alert|
          alert.add_info.add_parameter do |parameter|
            parameter.name = 'name'
            parameter.value = 'value'
          end
        end
        @original_parameter  = @alert.infos.first.parameters.first
        @xml_string = @alert.to_xml
        @xml_document = REXML::Document.new( @xml_string )
        @info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_1::Info::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
        @parameter_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_1::Parameter::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
        @parameter = RCAP::CAP_1_1::Parameter.from_xml_element( @parameter_xml_element )
      end

      it( 'should parse into the correct class' ) do
        @parameter.class.should == RCAP::CAP_1_1::Parameter
      end

      it( 'should parse the name correctly' ) do
        @parameter.name.should == @original_parameter.name
      end

      it( 'should parse the value correctly' ) do
        @parameter.value.should == @original_parameter.value
      end
    end
  end

  context( 'when exported' ) do
    before( :each ) do
      @parameter = RCAP::CAP_1_1::Parameter.new do |parameter|
         parameter.name  = 'name'
         parameter.value = 'value'
      end
    end

    context( 'to a hash' ) do
      it( 'should export correctly' ) do
        @parameter.to_h.should == { 'name' => 'value' }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rcap-2.4.1 spec/cap_1_1/parameter_spec.rb
rcap-2.4.0 spec/cap_1_1/parameter_spec.rb
rcap-2.3.0 spec/cap_1_1/parameter_spec.rb
rcap-2.2.1 spec/cap_1_1/parameter_spec.rb
rcap-2.2.0 spec/cap_1_1/parameter_spec.rb
rcap-2.1.0 spec/cap_1_1/parameter_spec.rb
rcap-2.0.2 spec/cap_1_1/parameter_spec.rb
rcap-2.0.1 spec/cap_1_1/parameter_spec.rb
rcap-2.0.0 spec/cap_1_1/parameter_spec.rb