Sha256: 488b67fc83546bc67d0a2085dc0e54ce3cb28587fc0724ca5f5f97fbaf151a44

Contents?: true

Size: 1.96 KB

Versions: 35

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'
require 'quick_travel/products/scheduled_trip'

describe QuickTravel::Products::ScheduledTrip do
  let(:params) {
    {
      product_type_id: 1,
      route_id: 1,
      forward: {
        first_travel_date: date,
        passenger_types: { '1' => '2' } # 2 adults
      }
    }
  }
  let(:date) { '2016-03-01' }
  subject(:products) {
    VCR.use_cassette 'basic_product_scheduled_trips' do
      QuickTravel::Products::ScheduledTrip.find(params)
    end
  }

  its(:size) { should == 4 }

  context 'first product' do
    subject(:product) { products.first }

    it { should be_normally_bookable }
    its(:price) { should eq 40.to_money }
    its(:from_route_stop) { should be nil }
    its(:to_route_stop) { should be nil }
  end

  context 'when date has no services' do
    subject(:unbookable_products) {
      VCR.use_cassette 'basic_product_scheduled_trips_unbookable' do
        QuickTravel::Products::ScheduledTrip.find(params)
      end
    }
    let(:date) { '2016-03-03' }

    it { should be_empty }
  end

  context 'multi sector' do
    let(:params) {
      {
        product_type_id: 6,
        route_id: 3,
        forward: {
          first_travel_date: date,
          from_route_stop_id: 5,
          to_route_stop_id: 14,
          passenger_types: { '1' => '2' } # 2 adults
        }
      }
    }
    let(:date) { '2016-03-01' }
    subject(:products) {
      VCR.use_cassette 'basic_product_scheduled_trips_multi_sector' do
        QuickTravel::Products::ScheduledTrip.find(params)
      end
    }

    its(:size) { should == 2 }

    context 'first product' do
      subject(:product) { products.first }

      it { should be_normally_bookable }
      its(:price) { should eq 30.to_money }
      its('from_route_stop.name') { should eq 'Adelaide Central Bus Station' }
      its('to_route_stop.name') { should eq 'Cape Jervis Ferry Terminal' }
      its(:from_route_stop_id) { should eq 5 }
      its(:to_route_stop_id) { should eq 14 }
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
quicktravel_client-3.1.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-3.0.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.9.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.8.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.7.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.6.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.5.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.4.1 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.4.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.3.1 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.3.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.2.2 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.2.1 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.2.0 spec/products/scheduled_trip_spec.rb
quicktravel_client-2.1.0 spec/products/scheduled_trip_spec.rb