Sha256: d910b3d67bf1bab0770cc08d7b7e828ea191a5ccbdccd8bcaea07ea1b4ed06af

Contents?: true

Size: 1.53 KB

Versions: 6

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true
describe Correios::CEP do
  describe '#web_service_url' do
    it 'default is Correios::CEP::Config::WEB_SERVICE_URL' do
      expect(Correios::CEP.web_service_url).to eq Correios::CEP::Config::WEB_SERVICE_URL
    end

    context 'when set web service URL' do
      let(:url) { 'http://ws.correios.com.br/cep' }

      around do |example|
        Correios::CEP.web_service_url = url
        example.run
        Correios::CEP.web_service_url = Correios::CEP::Config::WEB_SERVICE_URL
      end

      it 'returns the given web service URL' do
        expect(Correios::CEP.web_service_url).to eq url
      end
    end
  end

  describe '#proxy_url' do
    it 'default is empty' do
      expect(Correios::CEP.proxy_url).to eq ''
    end

    context 'when set proxy URL' do
      let(:url) { 'http://10.20.30.40:8888' }

      around do |example|
        Correios::CEP.proxy_url = url
        example.run
        Correios::CEP.proxy_url = ''
      end

      it 'returns the given proxy URL' do
        expect(Correios::CEP.proxy_url).to eq url
      end
    end
  end

  describe "#request_timeout" do
    it "default is 5" do
      expect(Correios::CEP.request_timeout).to eq 5
    end

    context "when set timeout" do
      it "returns timeout" do
        Correios::CEP.request_timeout = 3
        expect(Correios::CEP.request_timeout).to eq 3
      end

      it "returns timeout in seconds (integer)" do
        Correios::CEP.request_timeout = 2.123
        expect(Correios::CEP.request_timeout).to eq 2
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
correios-cep-0.6.8 spec/correios/cep_spec.rb
correios-cep-0.6.7 spec/correios/cep_spec.rb
correios-cep-0.6.6 spec/correios/cep_spec.rb
correios-cep-0.6.5 spec/correios/cep_spec.rb
correios-cep-0.6.4 spec/correios/cep_spec.rb
correios-cep-0.6.3 spec/correios/cep_spec.rb