correios-cep 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/CHANGELOG.md +1 -0
- data/README.md +4 -4
- data/correios-cep.gemspec +3 -2
- data/lib/correios/cep/address_finder.rb +1 -0
- data/lib/correios/cep/config.rb +9 -2
- data/lib/correios/cep/parser.rb +1 -0
- data/lib/correios/cep/version.rb +2 -1
- data/lib/correios/cep/web_service.rb +15 -16
- data/lib/correios/cep.rb +1 -0
- data/lib/correios-cep.rb +1 -0
- data/spec/correios/cep/address_finder_spec.rb +1 -2
- data/spec/correios/cep/parser_spec.rb +56 -57
- data/spec/correios/cep/web_service_spec.rb +1 -2
- data/spec/correios/cep_spec.rb +37 -11
- data/spec/spec_helper.rb +1 -0
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4abeb1ebfdf342e8d2db3a0b3f00d38ed97a7735
         | 
| 4 | 
            +
              data.tar.gz: 5e76ec6601bb51ee8098f107157e3f734b08d898
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: '091945d26d6d64709d2cd1dd6f31b851f5daee2f35025cba1024c9d873e1cec85f1d1f40ba92bc7d8ec5b32a36a12af1c06d3fc9e71df286bbc5c8056b296dfb'
         | 
| 7 | 
            +
              data.tar.gz: 720dc55e5e7bab49f76f49c51a17d408c044c13090deb5188dd8e0cacae9fe4e2a8b224a6ef1b79876bd43a693b0cd72b7b577fda36f523b5532405790e76cc8
         | 
    
        data/.rspec
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            | Version | Changes                                                                                                                                    |
         | 
| 2 2 | 
             
            | ------- | -------                                                                                                                                    |
         | 
| 3 | 
            +
            | 0.6.3   | Improve performance regarding strings.                                                                                                     |
         | 
| 3 4 | 
             
            | 0.6.2   | Update Ox gem to version `2.4`. [PR #14](https://github.com/prodis/correios-cep/pull/14)                                                   |
         | 
| 4 5 | 
             
            | 0.6.1   | Update LogMe gem to version `0.0.10`.                                                                                                      |
         | 
| 5 6 | 
             
            | 0.6.0   | Minimal required Ruby version from now is 2.0.0.                                                                                           |
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            # Correios CEP
         | 
| 2 2 |  | 
| 3 | 
            -
            Current available solutions to find Brazilian addresses by zipcode use an HTML form from [Correios web site](http://correios.com.br) to perform it, instead of to use a real API.
         | 
| 3 | 
            +
            Current available solutions to find Brazilian addresses by zipcode use an HTML form from [Correios web site](http://correios.com.br) website to perform it, instead of to use a real API.
         | 
| 4 4 |  | 
| 5 | 
            -
            The old solution works with an HTTP request to the form, followed by parsing  | 
| 5 | 
            +
            The old solution works with an HTTP request to the form, followed by parsing HTML result page. The huge problem here is when the Correios web site development team decides to modify some HTML element in the result page, even a layout update, it will break the parser logic for result.
         | 
| 6 6 |  | 
| 7 | 
            -
            Correios CEP gem solves this problem,  | 
| 7 | 
            +
            Correios CEP gem solves this problem, retrieving data directly from Correios database.
         | 
| 8 8 |  | 
| 9 9 | 
             
            
         | 
| 10 10 |  | 
| @@ -148,7 +148,7 @@ end | |
| 148 148 | 
             
            ### Contributors
         | 
| 149 149 | 
             
            - [Gabriel Givigier Guimarães (givigier)](https://github.com/givigier)
         | 
| 150 150 | 
             
            - [Maury M. Marques (maurymmarques)](https://github.com/maurymmarques)
         | 
| 151 | 
            -
            - [Rafael Garcia](https://github.com/rafbgarcia)
         | 
| 151 | 
            +
            - [Rafael Garcia (rafbgarcia)](https://github.com/rafbgarcia)
         | 
| 152 152 |  | 
| 153 153 |  | 
| 154 154 | 
             
            ## Contributing to correios-cep
         | 
    
        data/correios-cep.gemspec
    CHANGED
    
    | @@ -1,3 +1,4 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 1 2 | 
             
            lib = File.expand_path('../lib', __FILE__)
         | 
| 2 3 | 
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 3 4 | 
             
            require 'correios/cep/version'
         | 
| @@ -7,9 +8,9 @@ Gem::Specification.new do |spec| | |
| 7 8 | 
             
              spec.version       = Correios::CEP::VERSION
         | 
| 8 9 | 
             
              spec.author        = 'Prodis a.k.a. Fernando Hamasaki de Amorim'
         | 
| 9 10 | 
             
              spec.email         = 'prodis@gmail.com'
         | 
| 10 | 
            -
              spec.summary       = 'Correios CEP gem  | 
| 11 | 
            +
              spec.summary       = 'Correios CEP gem finds updated Brazilian addresses by zipcode, directly from Correios database. No HTML parsers.'
         | 
| 11 12 | 
             
              spec.description   = spec.summary
         | 
| 12 | 
            -
              spec.homepage      = ' | 
| 13 | 
            +
              spec.homepage      = 'https://github.com/prodis/correios-cep'
         | 
| 13 14 | 
             
              spec.license       = 'MIT'
         | 
| 14 15 |  | 
| 15 16 | 
             
              spec.files         = `git ls-files`.split($/)
         | 
    
        data/lib/correios/cep/config.rb
    CHANGED
    
    | @@ -1,8 +1,15 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 1 2 | 
             
            module Correios
         | 
| 2 3 | 
             
              module CEP
         | 
| 3 4 | 
             
                module Config
         | 
| 4 | 
            -
                   | 
| 5 | 
            -
                   | 
| 5 | 
            +
                  WEB_SERVICE_URL = 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente'
         | 
| 6 | 
            +
                  DEFAULT_REQUEST_TIMEOUT = 5 # seconds
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  attr_writer :web_service_url, :proxy_url, :request_timeout
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def web_service_url
         | 
| 11 | 
            +
                    @web_service_url ||= WEB_SERVICE_URL
         | 
| 12 | 
            +
                  end
         | 
| 6 13 |  | 
| 7 14 | 
             
                  def proxy_url
         | 
| 8 15 | 
             
                    @proxy_url ||= ''
         | 
    
        data/lib/correios/cep/parser.rb
    CHANGED
    
    
    
        data/lib/correios/cep/version.rb
    CHANGED
    
    
| @@ -1,13 +1,24 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 1 2 | 
             
            require 'net/https'
         | 
| 2 3 | 
             
            require 'uri'
         | 
| 3 4 |  | 
| 4 5 | 
             
            module Correios
         | 
| 5 6 | 
             
              module CEP
         | 
| 6 7 | 
             
                class WebService
         | 
| 7 | 
            -
                   | 
| 8 | 
            +
                  CONTENT_TYPE_HEADER = 'text/xml; charset=utf-8'
         | 
| 9 | 
            +
                  BODY_TEMPLATE = '<?xml version="1.0" encoding="UTF-8"?>' \
         | 
| 10 | 
            +
                                  '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"' \
         | 
| 11 | 
            +
                                  ' xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">' \
         | 
| 12 | 
            +
                                     '<soapenv:Header />' \
         | 
| 13 | 
            +
                                     '<soapenv:Body>' \
         | 
| 14 | 
            +
                                        '<cli:consultaCEP>' \
         | 
| 15 | 
            +
                                          '<cep>%{zipcode}</cep>' \
         | 
| 16 | 
            +
                                        '</cli:consultaCEP>' \
         | 
| 17 | 
            +
                                     '</soapenv:Body>' \
         | 
| 18 | 
            +
                                  '</soapenv:Envelope>'
         | 
| 8 19 |  | 
| 9 20 | 
             
                  def initialize
         | 
| 10 | 
            -
                    @uri = URI.parse( | 
| 21 | 
            +
                    @uri = URI.parse(Correios::CEP.web_service_url)
         | 
| 11 22 | 
             
                    @proxy_uri = URI.parse(Correios::CEP.proxy_url)
         | 
| 12 23 | 
             
                  end
         | 
| 13 24 |  | 
| @@ -46,22 +57,10 @@ module Correios | |
| 46 57 |  | 
| 47 58 | 
             
                  def build_request(zipcode)
         | 
| 48 59 | 
             
                    request = Net::HTTP::Post.new(uri.path)
         | 
| 49 | 
            -
                    request['Content-Type'] =  | 
| 50 | 
            -
                    request.body =  | 
| 60 | 
            +
                    request['Content-Type'] = CONTENT_TYPE_HEADER
         | 
| 61 | 
            +
                    request.body = BODY_TEMPLATE % { zipcode: zipcode }
         | 
| 51 62 | 
             
                    request
         | 
| 52 63 | 
             
                  end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                  def request_body(zipcode)
         | 
| 55 | 
            -
                    '<?xml version="1.0" encoding="UTF-8"?>' +
         | 
| 56 | 
            -
                    '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">' +
         | 
| 57 | 
            -
                       '<soapenv:Header />' +
         | 
| 58 | 
            -
                       '<soapenv:Body>' +
         | 
| 59 | 
            -
                          '<cli:consultaCEP>' +
         | 
| 60 | 
            -
                            "<cep>#{zipcode}</cep>" +
         | 
| 61 | 
            -
                          '</cli:consultaCEP>' +
         | 
| 62 | 
            -
                       '</soapenv:Body>' +
         | 
| 63 | 
            -
                    '</soapenv:Envelope>'
         | 
| 64 | 
            -
                  end
         | 
| 65 64 | 
             
                end
         | 
| 66 65 | 
             
              end
         | 
| 67 66 | 
             
            end
         | 
    
        data/lib/correios/cep.rb
    CHANGED
    
    
    
        data/lib/correios-cep.rb
    CHANGED
    
    
| @@ -1,6 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 1 2 | 
             
            # encoding: UTF-8
         | 
| 2 | 
            -
            require 'spec_helper'
         | 
| 3 | 
            -
             | 
| 4 3 | 
             
            describe Correios::CEP::Parser do
         | 
| 5 4 | 
             
              describe '#address' do
         | 
| 6 5 | 
             
                let(:expected_address) do
         | 
| @@ -17,21 +16,21 @@ describe Correios::CEP::Parser do | |
| 17 16 | 
             
                context 'when address is found' do
         | 
| 18 17 | 
             
                  context 'and does not have complement' do
         | 
| 19 18 | 
             
                    let(:xml) do
         | 
| 20 | 
            -
                      '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'  | 
| 21 | 
            -
                        '<soap:Body>'  | 
| 22 | 
            -
                          '<ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">'  | 
| 23 | 
            -
                            '<return>'  | 
| 24 | 
            -
                              '<bairro>Cavaleiro</bairro>'  | 
| 25 | 
            -
                              '<cep>54250610</cep>'  | 
| 26 | 
            -
                              '<cidade>Jaboatão dos Guararapes</cidade>'  | 
| 27 | 
            -
                              '<complemento></complemento>'  | 
| 28 | 
            -
                              '<complemento2></complemento2>'  | 
| 29 | 
            -
                              '<end>Rua Fernando Amorim</end>'  | 
| 30 | 
            -
                              '<id>0</id>'  | 
| 31 | 
            -
                              '<uf>PE</uf>'  | 
| 32 | 
            -
                            '</return>'  | 
| 33 | 
            -
                          '</ns2:consultaCEPResponse>'  | 
| 34 | 
            -
                        '</soap:Body>'  | 
| 19 | 
            +
                      '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' \
         | 
| 20 | 
            +
                        '<soap:Body>' \
         | 
| 21 | 
            +
                          '<ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">' \
         | 
| 22 | 
            +
                            '<return>' \
         | 
| 23 | 
            +
                              '<bairro>Cavaleiro</bairro>' \
         | 
| 24 | 
            +
                              '<cep>54250610</cep>' \
         | 
| 25 | 
            +
                              '<cidade>Jaboatão dos Guararapes</cidade>' \
         | 
| 26 | 
            +
                              '<complemento></complemento>' \
         | 
| 27 | 
            +
                              '<complemento2></complemento2>' \
         | 
| 28 | 
            +
                              '<end>Rua Fernando Amorim</end>' \
         | 
| 29 | 
            +
                              '<id>0</id>' \
         | 
| 30 | 
            +
                              '<uf>PE</uf>' \
         | 
| 31 | 
            +
                            '</return>' \
         | 
| 32 | 
            +
                          '</ns2:consultaCEPResponse>' \
         | 
| 33 | 
            +
                        '</soap:Body>' \
         | 
| 35 34 | 
             
                      '</soap:Envelope>'
         | 
| 36 35 | 
             
                    end
         | 
| 37 36 |  | 
| @@ -42,21 +41,21 @@ describe Correios::CEP::Parser do | |
| 42 41 |  | 
| 43 42 | 
             
                  context 'and has one complement' do
         | 
| 44 43 | 
             
                    let(:xml) do
         | 
| 45 | 
            -
                      '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'  | 
| 46 | 
            -
                        '<soap:Body>'  | 
| 47 | 
            -
                          '<ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">'  | 
| 48 | 
            -
                            '<return>'  | 
| 49 | 
            -
                              '<bairro>Cavaleiro</bairro>'  | 
| 50 | 
            -
                              '<cep>54250610</cep>'  | 
| 51 | 
            -
                              '<cidade>Jaboatão dos Guararapes</cidade>'  | 
| 52 | 
            -
                              '<complemento>de 1500 até o fim</complemento>'  | 
| 53 | 
            -
                              '<complemento2></complemento2>'  | 
| 54 | 
            -
                              '<end>Rua Fernando Amorim</end>'  | 
| 55 | 
            -
                              '<id>0</id>'  | 
| 56 | 
            -
                              '<uf>PE</uf>'  | 
| 57 | 
            -
                            '</return>'  | 
| 58 | 
            -
                          '</ns2:consultaCEPResponse>'  | 
| 59 | 
            -
                        '</soap:Body>'  | 
| 44 | 
            +
                      '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' \
         | 
| 45 | 
            +
                        '<soap:Body>' \
         | 
| 46 | 
            +
                          '<ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">' \
         | 
| 47 | 
            +
                            '<return>' \
         | 
| 48 | 
            +
                              '<bairro>Cavaleiro</bairro>' \
         | 
| 49 | 
            +
                              '<cep>54250610</cep>' \
         | 
| 50 | 
            +
                              '<cidade>Jaboatão dos Guararapes</cidade>' \
         | 
| 51 | 
            +
                              '<complemento>de 1500 até o fim</complemento>' \
         | 
| 52 | 
            +
                              '<complemento2></complemento2>' \
         | 
| 53 | 
            +
                              '<end>Rua Fernando Amorim</end>' \
         | 
| 54 | 
            +
                              '<id>0</id>' \
         | 
| 55 | 
            +
                              '<uf>PE</uf>' \
         | 
| 56 | 
            +
                            '</return>' \
         | 
| 57 | 
            +
                          '</ns2:consultaCEPResponse>' \
         | 
| 58 | 
            +
                        '</soap:Body>' \
         | 
| 60 59 | 
             
                      '</soap:Envelope>'
         | 
| 61 60 | 
             
                    end
         | 
| 62 61 |  | 
| @@ -69,21 +68,21 @@ describe Correios::CEP::Parser do | |
| 69 68 |  | 
| 70 69 | 
             
                  context 'and has two complements' do
         | 
| 71 70 | 
             
                    let(:xml) do
         | 
| 72 | 
            -
                      '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'  | 
| 73 | 
            -
                        '<soap:Body>'  | 
| 74 | 
            -
                          '<ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">'  | 
| 75 | 
            -
                            '<return>'  | 
| 76 | 
            -
                              '<bairro>Cavaleiro</bairro>'  | 
| 77 | 
            -
                              '<cep>54250610</cep>'  | 
| 78 | 
            -
                              '<cidade>Jaboatão dos Guararapes</cidade>'  | 
| 79 | 
            -
                              '<complemento>de 1500 até o fim</complemento>'  | 
| 80 | 
            -
                              '<complemento2>(zona mista)</complemento2>'  | 
| 81 | 
            -
                              '<end>Rua Fernando Amorim</end>'  | 
| 82 | 
            -
                              '<id>0</id>'  | 
| 83 | 
            -
                              '<uf>PE</uf>'  | 
| 84 | 
            -
                            '</return>'  | 
| 85 | 
            -
                          '</ns2:consultaCEPResponse>'  | 
| 86 | 
            -
                        '</soap:Body>'  | 
| 71 | 
            +
                      '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' \
         | 
| 72 | 
            +
                        '<soap:Body>' \
         | 
| 73 | 
            +
                          '<ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">' \
         | 
| 74 | 
            +
                            '<return>' \
         | 
| 75 | 
            +
                              '<bairro>Cavaleiro</bairro>' \
         | 
| 76 | 
            +
                              '<cep>54250610</cep>' \
         | 
| 77 | 
            +
                              '<cidade>Jaboatão dos Guararapes</cidade>' \
         | 
| 78 | 
            +
                              '<complemento>de 1500 até o fim</complemento>' \
         | 
| 79 | 
            +
                              '<complemento2>(zona mista)</complemento2>' \
         | 
| 80 | 
            +
                              '<end>Rua Fernando Amorim</end>' \
         | 
| 81 | 
            +
                              '<id>0</id>' \
         | 
| 82 | 
            +
                              '<uf>PE</uf>' \
         | 
| 83 | 
            +
                            '</return>' \
         | 
| 84 | 
            +
                          '</ns2:consultaCEPResponse>' \
         | 
| 85 | 
            +
                        '</soap:Body>' \
         | 
| 87 86 | 
             
                      '</soap:Envelope>'
         | 
| 88 87 | 
             
                    end
         | 
| 89 88 |  | 
| @@ -97,16 +96,16 @@ describe Correios::CEP::Parser do | |
| 97 96 |  | 
| 98 97 | 
             
                context 'when address is not found' do
         | 
| 99 98 | 
             
                  let(:xml) do
         | 
| 100 | 
            -
                    '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'  | 
| 101 | 
            -
                      '<soap:Body>'  | 
| 102 | 
            -
                        '<soap:Fault>'  | 
| 103 | 
            -
                          '<faultcode>soap:Server</faultcode>'  | 
| 104 | 
            -
                          '<faultstring>CEP NAO ENCONTRADO</faultstring>'  | 
| 105 | 
            -
                          '<detail>'  | 
| 106 | 
            -
                            '<ns2:SigepClienteException xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">CEP NAO ENCONTRADO</ns2:SigepClienteException>'  | 
| 107 | 
            -
                          '</detail>'  | 
| 108 | 
            -
                        '</soap:Fault>'  | 
| 109 | 
            -
                      '</soap:Body>'  | 
| 99 | 
            +
                    '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' \
         | 
| 100 | 
            +
                      '<soap:Body>' \
         | 
| 101 | 
            +
                        '<soap:Fault>' \
         | 
| 102 | 
            +
                          '<faultcode>soap:Server</faultcode>' \
         | 
| 103 | 
            +
                          '<faultstring>CEP NAO ENCONTRADO</faultstring>' \
         | 
| 104 | 
            +
                          '<detail>' \
         | 
| 105 | 
            +
                            '<ns2:SigepClienteException xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">CEP NAO ENCONTRADO</ns2:SigepClienteException>' \
         | 
| 106 | 
            +
                          '</detail>' \
         | 
| 107 | 
            +
                        '</soap:Fault>' \
         | 
| 108 | 
            +
                      '</soap:Body>' \
         | 
| 110 109 | 
             
                    '</soap:Envelope>'
         | 
| 111 110 | 
             
                  end
         | 
| 112 111 |  | 
    
        data/spec/correios/cep_spec.rb
    CHANGED
    
    | @@ -1,33 +1,59 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 3 2 | 
             
            describe Correios::CEP do
         | 
| 3 | 
            +
              describe '#web_service_url' do
         | 
| 4 | 
            +
                it 'default is Correios::CEP::Config::WEB_SERVICE_URL' do
         | 
| 5 | 
            +
                  expect(Correios::CEP.web_service_url).to eq Correios::CEP::Config::WEB_SERVICE_URL
         | 
| 6 | 
            +
                end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                context 'when set web service URL' do
         | 
| 9 | 
            +
                  let(:url) { 'http://ws.correios.com.br/cep' }
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  around do |example|
         | 
| 12 | 
            +
                    Correios::CEP.web_service_url = url
         | 
| 13 | 
            +
                    example.run
         | 
| 14 | 
            +
                    Correios::CEP.web_service_url = Correios::CEP::Config::WEB_SERVICE_URL
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  it 'returns the given web service URL' do
         | 
| 18 | 
            +
                    expect(Correios::CEP.web_service_url).to eq url
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 4 23 | 
             
              describe '#proxy_url' do
         | 
| 5 24 | 
             
                it 'default is empty' do
         | 
| 6 | 
            -
                  expect(Correios::CEP.proxy_url).to  | 
| 25 | 
            +
                  expect(Correios::CEP.proxy_url).to eq ''
         | 
| 7 26 | 
             
                end
         | 
| 8 27 |  | 
| 9 28 | 
             
                context 'when set proxy URL' do
         | 
| 10 | 
            -
                   | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 29 | 
            +
                  let(:url) { 'http://10.20.30.40:8888' }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  around do |example|
         | 
| 32 | 
            +
                    Correios::CEP.proxy_url = url
         | 
| 33 | 
            +
                    example.run
         | 
| 34 | 
            +
                    Correios::CEP.proxy_url = ''
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  it 'returns the given proxy URL' do
         | 
| 38 | 
            +
                    expect(Correios::CEP.proxy_url).to eq url
         | 
| 13 39 | 
             
                  end
         | 
| 14 40 | 
             
                end
         | 
| 15 41 | 
             
              end
         | 
| 16 42 |  | 
| 17 43 | 
             
              describe "#request_timeout" do
         | 
| 18 44 | 
             
                it "default is 5" do
         | 
| 19 | 
            -
                  expect(Correios::CEP.request_timeout).to  | 
| 45 | 
            +
                  expect(Correios::CEP.request_timeout).to eq 5
         | 
| 20 46 | 
             
                end
         | 
| 21 47 |  | 
| 22 48 | 
             
                context "when set timeout" do
         | 
| 23 49 | 
             
                  it "returns timeout" do
         | 
| 24 | 
            -
                    Correios::CEP. | 
| 25 | 
            -
                    expect(Correios::CEP.request_timeout).to  | 
| 50 | 
            +
                    Correios::CEP.request_timeout = 3
         | 
| 51 | 
            +
                    expect(Correios::CEP.request_timeout).to eq 3
         | 
| 26 52 | 
             
                  end
         | 
| 27 53 |  | 
| 28 54 | 
             
                  it "returns timeout in seconds (integer)" do
         | 
| 29 | 
            -
                    Correios::CEP. | 
| 30 | 
            -
                    expect(Correios::CEP.request_timeout).to  | 
| 55 | 
            +
                    Correios::CEP.request_timeout = 2.123
         | 
| 56 | 
            +
                    expect(Correios::CEP.request_timeout).to eq 2
         | 
| 31 57 | 
             
                  end
         | 
| 32 58 | 
             
                end
         | 
| 33 59 | 
             
              end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: correios-cep
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.6. | 
| 4 | 
            +
              version: 0.6.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Prodis a.k.a. Fernando Hamasaki de Amorim
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017-03- | 
| 11 | 
            +
            date: 2017-03-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: log-me
         | 
| @@ -122,7 +122,7 @@ dependencies: | |
| 122 122 | 
             
                - - "~>"
         | 
| 123 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 124 | 
             
                    version: '2.3'
         | 
| 125 | 
            -
            description: Correios CEP gem  | 
| 125 | 
            +
            description: Correios CEP gem finds updated Brazilian addresses by zipcode, directly
         | 
| 126 126 | 
             
              from Correios database. No HTML parsers.
         | 
| 127 127 | 
             
            email: prodis@gmail.com
         | 
| 128 128 | 
             
            executables:
         | 
| @@ -153,7 +153,7 @@ files: | |
| 153 153 | 
             
            - spec/correios/cep_spec.rb
         | 
| 154 154 | 
             
            - spec/fixtures/cassettes/correios_consulta_cep_ok.yml
         | 
| 155 155 | 
             
            - spec/spec_helper.rb
         | 
| 156 | 
            -
            homepage:  | 
| 156 | 
            +
            homepage: https://github.com/prodis/correios-cep
         | 
| 157 157 | 
             
            licenses:
         | 
| 158 158 | 
             
            - MIT
         | 
| 159 159 | 
             
            metadata: {}
         | 
| @@ -176,8 +176,8 @@ rubyforge_project: | |
| 176 176 | 
             
            rubygems_version: 2.6.8
         | 
| 177 177 | 
             
            signing_key: 
         | 
| 178 178 | 
             
            specification_version: 4
         | 
| 179 | 
            -
            summary: Correios CEP gem  | 
| 180 | 
            -
               | 
| 179 | 
            +
            summary: Correios CEP gem finds updated Brazilian addresses by zipcode, directly from
         | 
| 180 | 
            +
              Correios database. No HTML parsers.
         | 
| 181 181 | 
             
            test_files:
         | 
| 182 182 | 
             
            - spec/correios/cep/address_finder_spec.rb
         | 
| 183 183 | 
             
            - spec/correios/cep/parser_spec.rb
         |