Sha256: 842d4bba829fe56c9c1397100c10107be52905b9114db30e8149dfc001a40b1d

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'sms77/endpoint'
require 'json'

RSpec.describe Sms77, 'pricing' do
  it 'returns all countries pricing as json' do
    stub = {
      countCountries: 1,
      countNetworks: 4,
      countries: [
        {
          countryCode: 'AT',
          countryName: 'Austria',
          countryPrefix: '43',
          networks: [
            {
              comment: '',
              features: [],
              mcc: '232',
              mncs: ['02'],
              networkName: 'A1 Telekom Austria',
              price: 0.075
            },
            {
              comment: '',
              features: %w[alpha Numeric dlr sc],
              mcc: '232',
              mncs: ['01'],
              networkName: 'A1 Telekom Austria (A1.net)',
              price: 0.075
            }
          ]
        }
      ]
    }

    res = Helper.get(Sms77::Endpoint::PRICING, stub)
    countries = res[:countries]

    expect(res).to be_a(Hash)
    expect(res[:countCountries]).to be_a(Integer)
    expect(res[:countNetworks]).to be_a(Integer)
    expect(countries).to be_a(Array)

    countries.each do |country|
      networks = country[:networks]

      expect(country).to be_a(Hash)
      expect(country[:countryCode]).to be_a(String)
      expect(country[:countryName]).to be_a(String)
      expect(country[:countryPrefix]).to be_a(String)
      expect(networks).to be_a(Array)

      networks.each do |network|
        mncs = network[:mncs]
        features = network[:features]

        expect(network).to be_a(Hash)
        expect(network[:mcc]).to be_a(String)
        expect(mncs).to be_a(Array)
        mncs.each do |mnc|
          expect(mnc).to be_a(String)
        end
        expect(network[:networkName]).to be_a(String)
        expect(network[:price]).to be_a(Float)
        expect(features).to be_a(Array)
        features.each do |feature|
          expect(feature).to be_a(String)
        end
        expect(network[:comment]).to be_a(String)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sms77-0.2.0 spec/sms77/pricing_spec.rb
sms77-0.1.0 spec/sms77/pricing_spec.rb