Sha256: 86dac7b5f81e60cfb7818467c5f778d271d49cef6e848e2fd50110a753590a4d

Contents?: true

Size: 1.61 KB

Versions: 6

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8

require "spec_helper"

describe DpdApi::Geography do
  include Savon::SpecHelper
  before(:all) { savon.mock!   }
  after(:all)  { savon.unmock! }

  let(:auth) do
    { auth: {
      client_number: ENV['DPD_CLIENT_NUMBER'] || '234',
      client_key:    ENV['DPD_CLIENT_KEY']    || '123'
    } }
  end
  let(:message) { auth }

  before { enable_debug! }

  context ".cities_cash_pay" do
    let(:fixture) { File.read("spec/fixtures/dpd_api/geography/cities_cash_pay.xml") }

    it "is success" do
      savon.expects(:get_cities_cash_pay).with(message: message).returns(fixture)

      response = described_class.cities_cash_pay
      expect(response.first).to have_key(:city_id)
      expect(response.first).to have_key(:country_code)
      expect(response.first).to have_key(:region_code)
      expect(response.first).to have_key(:region_name)
      expect(response.first).to have_key(:city_name)
    end
  end

  context ".terminals_self_delivery" do
    let(:fixture) { File.read("spec/fixtures/dpd_api/geography/terminals_self_delivery.xml") }

    it "is success" do
      savon.expects(:get_terminals_self_delivery2).with(message: message).returns(fixture)

      response = described_class.terminals_self_delivery
      expect(response.first).to have_key(:terminal)
    end
  end

  context ".parcel_shops" do
    let(:fixture) { File.read("spec/fixtures/dpd_api/geography/parcel_shops.xml") }

    it "is success" do
      savon.expects(:get_parcel_shops).with(message: message).returns(fixture)

      response = described_class.parcel_shops
      expect(response.first).to have_key(:parcel_shop)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dpd_api-0.1.10 spec/lib/dpd_api/geography_spec.rb
dpd_api-0.1.9 spec/lib/dpd_api/geography_spec.rb
dpd_api-0.1.8 spec/lib/dpd_api/geography_spec.rb
dpd_api-0.1.7 spec/lib/dpd_api/geography_spec.rb
dpd_api-0.1.6 spec/lib/dpd_api/geography_spec.rb
dpd_api-0.1.5 spec/lib/dpd_api/geography_spec.rb