Sha256: 9fbc30df3d5f69c5f805aa15da5f944359b9aae5e2f20eca74d29683d0f747a5

Contents?: true

Size: 1.47 KB

Versions: 13

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe( RCAP::CAP_1_2::Geocode ) do
  context( 'when initialised' ) do
    context( 'from XML' ) do
      before( :each ) do
        @original_geocode = RCAP::CAP_1_2::Geocode.new( :name => 'name', :value => 'value' )
        @alert = RCAP::CAP_1_2::Alert.new( :infos => RCAP::CAP_1_2::Info.new( :areas => RCAP::CAP_1_2::Area.new( :geocodes => @original_geocode )))
        @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 )
        @area_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_2::Area::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
        @geocode_xml_element = RCAP.xpath_first( @area_xml_element, RCAP::CAP_1_2::Geocode::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
        @geocode = RCAP::CAP_1_2::Geocode.from_xml_element( @geocode_xml_element )
      end

      it( 'should parse the name correctly' ) do
        @geocode.name.should == @original_geocode.name
      end

      it( 'should parse the value correctly' ) do
        @geocode.value.should == @original_geocode.value
      end
    end
  end

  context( 'when exported' ) do
    before( :each ) do
      @geocode = RCAP::CAP_1_2::Geocode.new( :name => 'name', :value => 'value' )
    end

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rcap-1.2.3 spec/cap_1_2/geocode_spec.rb
rcap-1.2.2 spec/cap_1_2/geocode_spec.rb
rcap-1.2.1 spec/cap_1_2/geocode_spec.rb
rcap-1.2.0 spec/cap_1_2/geocode_spec.rb
rcap-1.1.1 spec/cap_1_2/geocode_spec.rb
rcap-1.1.0 spec/cap_1_2/geocode_spec.rb
rcap-1.0.1 spec/cap_1_2/geocode_spec.rb
rcap-1.0.0 spec/cap_1_2/geocode_spec.rb
rcap-1.0.0.rc.5 spec/cap_1_2/geocode_spec.rb
rcap-1.0.0.rc.4 spec/cap_1_2/geocode_spec.rb
rcap-1.0.0.rc.3 spec/cap_1_2/geocode_spec.rb
rcap-1.0.0.rc.2 spec/cap_1_2/geocode_spec.rb
rcap-1.0.0.rc.1 spec/cap_1_2/geocode_spec.rb