Sha256: 2b65a1047031d6a6b4d2a89e2671bced9ea04ad94c005b2f32996c0edff36fb7

Contents?: true

Size: 1.72 KB

Versions: 11

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe Ratis::Route do
  before do
    Ratis.reset
    Ratis.configure do |config|
      config.endpoint  = 'http://example.com/soap.cgi'
      config.namespace = 'TEST_NS'
    end
  end

  describe '#all' do

    before do
      stub_atis_request.to_return( atis_response 'Allroutes', '1.5', '0', <<-BODY )
        <Routes>
          0, N, S
          1, E, W
        </Routes>
      BODY

      @all_routes = Ratis::Route.all
    end

    it 'only makes one request' do
      an_atis_request.should have_been_made.times 1
    end

    it 'gets all routes' do
      @all_routes.should have(2).items
    end

    it 'gets all route directions' do
      @all_routes.each do |route|
        route.should have(2).directions
      end
    end

  end

  describe '#timetable' do

    let(:route) { Ratis::Route.new '0', ['N', 'S'] }

    before do
      resp = atis_response_timetable({ :route => '0', :direction => 'N', :service_type => 'W', :operator => 'OP', :effective => '01/15/12' })
      stub_atis_request.to_return( atis_response 'Timetable', '1.1', '0', resp)

      @timetable = route.timetable :direction => 'N', :service_type => 'W'
    end

    it 'only makes one request' do
      an_atis_request.should have_been_made.times 1
    end

    it 'assigns settings correctly' do
      @timetable.should_not be_nil

      @timetable.route_short_name.should eql '0'
      @timetable.direction.should eql 'N'
      @timetable.service_type.should eql 'W'
      @timetable.operator.should eql 'OP'
      @timetable.effective.should eql '01/15/12'
    end

  end

  it 'should initialize' do
    route = Ratis::Route.new '123', ['N', 'S']

    route.short_name.should eql '123'
    route.directions.should eql ['N', 'S']
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ratis-3.2.1 spec/ratis/route_spec.rb
ratis-3.2.0 spec/ratis/route_spec.rb
ratis-3.1.8 spec/ratis/route_spec.rb
ratis-3.1.7 spec/ratis/route_spec.rb
ratis-3.1.6 spec/ratis/route_spec.rb
ratis-3.1.5.1 spec/ratis/route_spec.rb
ratis-3.1.5 spec/ratis/route_spec.rb
ratis-3.1.4 spec/ratis/route_spec.rb
ratis-3.1.3 spec/ratis/route_spec.rb
ratis-3.1.2 spec/ratis/route_spec.rb
ratis-3.1.1 spec/ratis/route_spec.rb