Sha256: 52c7cd0bc9b1b3a75574cfa8b789c52310dd838a27b86feddb1a2170062943e6
Contents?: true
Size: 1.58 KB
Versions: 9
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' describe( RCAP::CAP_1_0::EventCode ) do context( 'when initialised' ) do context( 'from XML' ) do before( :each ) do @original_event_code = RCAP::CAP_1_0::EventCode.new do |event_code| event_code.name = 'name' event_code.value = 'value' end @alert = RCAP::CAP_1_0::Alert.new @alert.add_info.event_codes << @original_event_code @xml_string = @alert.to_xml @xml_document = REXML::Document.new( @xml_string ) @info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS ) @event_code_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_0::EventCode::XPATH, RCAP::CAP_1_0::Alert::XMLNS ) @event_code = RCAP::CAP_1_0::EventCode.from_xml_element( @event_code_xml_element ) end it( 'should parse into the correct class' ) do @event_code.class.should == RCAP::CAP_1_0::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_0::EventCode.new do |event_code| event_code.name = 'name' event_code.value = 'value' end 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