Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adicionando o método info para o boleto #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Criando testes para o método info do Boleto
  • Loading branch information
Jonhnes Lopes committed Oct 19, 2018
commit 0822806022e4cb3f5fb753f47dd305fa94247b52
4 changes: 4 additions & 0 deletions lib/pjbank/recebimento/boleto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def credenciamento(dados)
def impressao(dados)
http.post("#{base_url_path}/:credencial/transacoes/lotes", payload: dados)
end

def info
http.get("#{base_url_path}/:credencial")
end
end
end
end
28 changes: 28 additions & 0 deletions spec/pjbank/recebimento/boleto_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,32 @@
end
end
end

describe "#info" do
context "when success" do
it "returns credencial information" do
VCR.use_cassette("recebimento/boleto/info/success") do
resposta = subject.info
expect(resposta).to be_an(OpenStruct)
expect(resposta.cnpj).to be_an(String)
end
end
end

context "when failure" do
let(:chave) {'cachorro'}

context "when validation error (400)" do
it "raises PJBank::RequestError" do
VCR.use_cassette("recebimento/boleto/info/erro_400") do
expect { subject.info }.to raise_error do |error|
expect(error).to be_a(PJBank::RequestError)
expect(error.message).to eql("Conta não encontrada.")
expect(error.code).to eql(400)
end
end
end
end
end
end
end
54 changes: 54 additions & 0 deletions spec/vcr_cassettes/recebimento/boleto/info/erro_400.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions spec/vcr_cassettes/recebimento/boleto/info/success.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.