Sha256: 9882012cd43d3092b7f43c65a4a34159bdb01df29e0a47459c6b428dcf8042ca

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

require 'spec_helper'
require 'quick_travel/adapter'

describe QuickTravel::Adapter do
  let(:response) { double code: 200, parsed_response: parsed_response }
  let(:parsed_response) { { test: true } }

  before do
    allow(QuickTravel::Api).to receive(:post).and_return(response)
  end

  context 'when the query contains empty arrays' do
    let(:url) { 'http://test.quicktravel.com.au' }
    let(:query) {
      {
        test: true,
        empty_array: [],
        sub_hash: { id: 42, values: [] }
      }
    }

    before do
      QuickTravel::Adapter.post_and_validate(url, query)
    end

    let(:expected_body) {
      {
        test: true,
        sub_hash: { id: 42 },
        access_key: an_instance_of(String)
      }
    }

    let(:expected_params) { a_hash_including body: expected_body }

    specify { expect(QuickTravel::Api).to have_received(:post).with(url, expected_params) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quicktravel_client-2.3.1 spec/adapter_spec.rb