Sha256: bcdae8c8521a96b553f87e53d82a02b5c4411be7ad5c142e4153481cb2f01f0c

Contents?: true

Size: 1.58 KB

Versions: 9

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe( RCAP::CAP_1_2::EventCode ) do
  before( :each ) do
    @event_code_builder = lambda do |event_code|
      event_code.name = 'name'
      event_code.value = 'value'
    end
  end

  context( 'when initialised' ) do
    context( 'from XML' ) do
      before( :each ) do
        @original_event_code = RCAP::CAP_1_2::EventCode.new( &@event_code_builder )
        @alert = RCAP::CAP_1_2::Alert.new
        @alert.add_info.add_event_code( &@event_code_builder )
        @xml_string = @alert.to_xml
        @xml_document = REXML::Document.new( @xml_string )
        @info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
        @event_code_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_2::EventCode::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
        @event_code = RCAP::CAP_1_2::EventCode.from_xml_element( @event_code_xml_element )
      end

      it( 'should parse into the correct class' ) do
        @event_code.class.should == RCAP::CAP_1_2::EventCode
      end

      it( 'should parse the name correctly' ) do
        @event_code.name.should == @original_event_code.name
      end

      it( 'should parse the value correctly' ) do
        @event_code.value.should == @original_event_code.value
      end
    end
  end

  context( 'when exported' ) do
    before( :each ) do
      @event_code = RCAP::CAP_1_2::EventCode.new( &@event_code_builder )
    end

    context( 'to a hash' ) do
      it( 'should export correctly' ) do
        @event_code.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_2/event_code_spec.rb
rcap-2.4.0 spec/cap_1_2/event_code_spec.rb
rcap-2.3.0 spec/cap_1_2/event_code_spec.rb
rcap-2.2.1 spec/cap_1_2/event_code_spec.rb
rcap-2.2.0 spec/cap_1_2/event_code_spec.rb
rcap-2.1.0 spec/cap_1_2/event_code_spec.rb
rcap-2.0.2 spec/cap_1_2/event_code_spec.rb
rcap-2.0.1 spec/cap_1_2/event_code_spec.rb
rcap-2.0.0 spec/cap_1_2/event_code_spec.rb