<commit_before>require 'spec_helper'
require 'helpers/vcr_helper'
require_relative '../../../lib/southwest/reservation'

describe Southwest::Reservation do
  let(:last_name) { 'Bar' }
  let(:first_name) { 'Fuu' }
  let(:record_locator) { 'ABC123' }

  subject {
    Southwest::Reservation.new(
      last_name: last_name,
      first_name: first_name,
      record_locator: record_locator)
  }

  describe '#retrieve_reservation' do
    it 'returns upComingInfo' do
      VCR.use_cassette 'viewAirReservation' do
        expect(JSON.parse(subject.retrieve_reservation.body)['upComingInfo']).to_not eql(nil)
      end
    end
  end
end<commit_msg>test for JSON keys returned for reservation information<commit_after>require 'spec_helper'
require 'helpers/vcr_helper'
require_relative '../../../lib/southwest/reservation'

describe Southwest::Reservation do
  let(:last_name) { 'Bar' }
  let(:first_name) { 'Fuu' }
  let(:record_locator) { 'ABC123' }

  subject {
    Southwest::Reservation.new(
      last_name: last_name,
      first_name: first_name,
      record_locator: record_locator)
  }

  describe '#retrieve_reservation' do
    let(:response_json) { JSON.parse(subject.retrieve_reservation.body) }
    let(:expected_person_keys) {
      ["isCompanion", "cnclFirstName", "confirmationNumber", "Depart2", "Depart1", "cnclLastName", "passengerName0", "TripName", "isFlNotifAvailable", "cnclConfirmNo", "arrivalCityName"]
    }

    let(:expected_flight_keys) {
      ["departCity", "arrivalCity", "departFlightNo"]
    }

    it 'returns upComingInfo' do
      VCR.use_cassette 'viewAirReservation' do
        expect(response_json['upComingInfo']).to_not eql(nil)
      end
    end

    it 'contains the correct keys for each person on the reservation' do
      VCR.use_cassette 'viewAirReservation' do
        response_json['upComingInfo'].each do |person|
          expect(person).to include(*expected_person_keys)
        end
      end
    end

    it 'contains the correct information for each flight' do
      VCR.use_cassette 'viewAirReservation' do
        response_json['upComingInfo'].each do |person|
          person.select { |k,v| k =~ /Depart/ }.each do |key, flight|
            expect(flight).to include(*expected_flight_keys)
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11516731855714907, 'fraction_numerical': 0.003911342894393742, 'mean_word_length': 3.531496062992126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '960654', 'n_tokens_mistral': 773, 'n_tokens_neox': 742, 'n_words': 154}