Created
January 24, 2013 17:58
-
-
Save kibaekr/4625785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ratis | |
class Area | |
attr_accessor :area, :description | |
def self.all | |
response = Request.get 'Getareas' | |
return [] unless response.success? | |
response.to_array(:getareas_response, :areainfo).map do |areainfo| | |
atis_area = Area.new | |
atis_area.area = areainfo[:area] | |
atis_area.description = areainfo[:description] | |
atis_area | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Ratis::Area do | |
before do | |
stub_atis_request.to_return( atis_response 'Getareas', '1.0', '0', <<-BODY ) | |
<Areainfo> | |
<Area>Area1</Area> | |
<Description>D1</Description> | |
</Areainfo> | |
<Areainfo> | |
<Area>Area2</Area> | |
<Description>D2</Description> | |
</Areainfo> | |
BODY | |
@areas = Ratis::Area.all | |
end | |
it 'only makes one request' do | |
an_atis_request.should have_been_made.times 1 | |
end | |
it 'requests the correct SOAP action' do | |
an_atis_request_for('Getareas').should have_been_made | |
end | |
it 'should return all areas' do | |
@areas.should have(2).items | |
@areas[0].area.should eql 'Area1' | |
@areas[0].description.should eql 'D1' | |
@areas[1].area.should eql 'Area2' | |
@areas[1].description.should eql 'D2' | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment