Sha256: 88dfe69ac9e18ffdd2e5d6ffd8a1e144acf9722ce36349fed807d8dbb19d5f90

Contents?: true

Size: 1.88 KB

Versions: 13

Compression:

Stored size: 1.88 KB

Contents

require 'test_helper'

class TicketsBookingTest < Minitest::Test
  def tickets_booking
    Gillbus::TicketsBooking::Response.parse_string(File.read('test/responses/ticketsBooking.xml'))
  end

  def test_number
    assert_equal('8472', tickets_booking.tickets.first.ticket_number)
  end

  def test_total
    assert_equal(Money.new(110_00, 'UAH'), tickets_booking.tickets.first.total_amount)
  end

  def test_params_generation_with_no_luggage
    request = Gillbus::TicketsBooking::Request.new(
      passengers: [
        { },
        { },
      ],
    )
    expected_params = {
      passenger0discountValue: '0.0',
      passenger1discountValue: '0.0',
    }
    assert_equal expected_params, request.params
  end

  def test_params_generation_with_luggage_with_one_segment
    request = Gillbus::TicketsBooking::Request.new(
      passengers: [
        {
          luggage: [1],
        },
        {
          luggage: [2],
        }
      ],
    )
    expected_params = {
      passenger0discountValue: '0.0',
      passenger0baggageCount: 1,
      passenger1discountValue: '0.0',
      passenger1baggageCount: 2,
    }
    assert_equal expected_params, request.params
  end

  def test_params_generation_with_baggage_with_two_segments
    request = Gillbus::TicketsBooking::Request.new(
      passengers: [
        {
          segments_luggage: [0, 1],
        },
        {
          segments_luggage: [1, 0],
        }
      ],
    )
    expected_params = {
      passenger0discountValue: '0.0',
      passenger0segment0baggageCount: 0,
      passenger0segment1baggageCount: 1,
      passenger1discountValue: '0.0',
      passenger1segment0baggageCount: 1,
      passenger1segment1baggageCount: 0,
    }
    assert_equal expected_params, request.params
  end

  def test_parse_is_luggage_field
    response = tickets_booking
    ticket = response.tickets.first

    assert_equal true, ticket.is_luggage
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gillbus-0.23.0 test/tickets_booking_test.rb
gillbus-0.22.9 test/tickets_booking_test.rb
gillbus-0.22.8 test/tickets_booking_test.rb
gillbus-0.22.7 test/tickets_booking_test.rb
gillbus-0.22.6 test/tickets_booking_test.rb
gillbus-0.22.5 test/tickets_booking_test.rb
gillbus-0.22.4 test/tickets_booking_test.rb
gillbus-0.22.3 test/tickets_booking_test.rb
gillbus-0.22.2 test/tickets_booking_test.rb
gillbus-0.22.1 test/tickets_booking_test.rb
gillbus-0.22.0 test/tickets_booking_test.rb
gillbus-0.21.0 test/tickets_booking_test.rb
gillbus-0.20.9 test/tickets_booking_test.rb