Sha256: 592c295c1b4ae2c21af323b199665bdde6ebd68873cecb6ba21445e44e189dc5

Contents?: true

Size: 930 Bytes

Versions: 1

Compression:

Stored size: 930 Bytes

Contents

RSpec.describe ViaCep::Address do
  describe '#initialize' do
    context 'when a valid CEP is passed' do
      subject(:address) { ViaCep::Address.new('80210130') }

      it 'returns the Address' do
        expect(address.address).not_to be_empty
      end
    end

    context 'when a invalid CEP is passed' do
      it 'raises ViaCep::ApiRequestError' do
        expect { ViaCep::Address.new('000000') }.
          to raise_error(ViaCep::ApiRequestError)
      end
    end

    context 'when a low timeout is specified' do
      it 'raises a Timeout::Error' do
        expect { ViaCep::Address.new('80210130', timeout: 0.001) }.
          to raise_error(Timeout::Error)
      end
    end

    context 'when a regular timeout is specified' do
      subject(:address) { ViaCep::Address.new('80210130', timeout: 25) }

      it 'returns the Address' do
        expect(address.address).not_to be_empty
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
viacep-2.0.1 spec/address_spec.rb