# encoding: UTF-8 require 'spec_helper' describe Correios::CEP::Parser do describe '#address' do context 'when address is found' do let(:xml) do "" + "" + "" + "" + "" + "Cavaleiro" + "54250610" + "Jaboatão dos Guararapes" + "de 1500 até o fim" + "(zona mista)" + "Rua Fernando Amorim" + "0" + "PE" + "" + "" + "" + "" end let(:expected_address) do { address: 'Rua Fernando Amorim', neighborhood: 'Cavaleiro', city: 'Jaboatão dos Guararapes', state: 'PE', zipcode: '54250610', complement: 'de 1500 até o fim (zona mista)' } end it 'returns address' do expect(subject.address(xml)).to eq expected_address end end context 'when address is not found' do let(:xml) do "" + "" + "" + "" + "" + "" end it 'returns nil' do expect(subject.address(xml)).to be_nil end end end end