Sha256: d9b198737133d907f801b87da5deac7c6066228c9d8d6b9aab32508637816eaa

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe Ratis::Routes do
  before do
    Ratis.reset
    Ratis.configure do |config|
      config.endpoint   = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
      config.namespace  = 'PX_WEB'
    end
  end

  let(:empty_body){ {:allroutes2_response => {:routes => []}} }

  describe '#all' do
    it 'returns all routes' do
      response = Ratis::Routes.all
      expect(response).to have(111).items
      expect(response.all?{|rte| rte.is_a?(Ratis::Route) }).to be_true
    end

    it 'only makes one request' do
      Ratis::Request.should_receive(:get).once.and_call_original
      Ratis::Routes.all
    end

    it 'requests the correct SOAP action' do
      Ratis::Request.should_receive(:get) do |action, options|
                       action.should eq('Allroutes2')
                     end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running

      Ratis::Routes.all
    end

    it 'should set directions and short_name to variables' do
      response = Ratis::Routes.all
      route    = response.first

      expect(response).to be_a(Array)
      expect(route).to be_a(Ratis::Route)
      expect(route.short_name).to eq('0')
      expect(route.directions).to have(2).directions
      expect(route.directions).to include('N')
      expect(route.directions).to include('S')
    end

  end

  describe '#timetable' do
    it "description" do
      pending
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ratis-3.3.6 spec/ratis/routes_spec.rb
ratis-3.3.5 spec/ratis/routes_spec.rb
ratis-3.3.4 spec/ratis/routes_spec.rb
ratis-3.3.3 spec/ratis/routes_spec.rb
ratis-3.3.2 spec/ratis/routes_spec.rb
ratis-3.3.1 spec/ratis/routes_spec.rb
ratis-3.3.0 spec/ratis/routes_spec.rb