Skip to content

Commit 1288966

Browse files
committed
Add specs for Iugu::Charge.create
1 parent 954e866 commit 1288966

File tree

3 files changed

+100
-14
lines changed

3 files changed

+100
-14
lines changed

spec/cassettes/Iugu_Charge/_create/should_create_a_charge.yml

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/charge_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'spec_helper'
2+
3+
describe Iugu::Charge do
4+
describe '.create' do
5+
it 'should create a charge', :vcr do
6+
charge = Iugu::Charge.create(method: 'bank_slip',
7+
payer: { name: 'Awesome Customer',
8+
cpf_cnpj: '15111975000164',
9+
address: { zip_code: '29190560', number: '100'} },
10+
items: [[{ quantity: 1,
11+
price_cents: 5000,
12+
description: 'item 1' }]],
13+
currency: 'BRL',
14+
15+
16+
expect(charge.url).to_not be_nil
17+
expect(charge.pdf).to_not be_nil
18+
expect(charge.invoice_id).to_not be_nil
19+
expect(charge.identification).to_not be_nil
20+
end
21+
end
22+
end

spec/invoice_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@
33
describe Iugu::Invoice do
44
describe '.create' do
55
it 'should create an invoice for credit card payment', :vcr do
6-
invoice = Iugu::Invoice.create(email: "[email protected]",
7-
due_date: "2017-11-30",
8-
items: [{price_cents: 100, description: "Rosquinha", quantity: 99}],
9-
payable_with:"credit_card")
6+
invoice = Iugu::Invoice.create(email: '[email protected]',
7+
due_date: '2017-11-30',
8+
items: [{ price_cents: 100, description: 'Rosquinha', quantity: 99 }],
9+
payable_with: 'credit_card')
1010

1111
expect(invoice.is_new?).to be_falsy
12-
expect(invoice.email).to eq("[email protected]")
13-
expect(invoice.due_date).to eq("2017-11-30")
14-
expect(invoice.status).to eq("pending")
12+
expect(invoice.email).to eq('[email protected]')
13+
expect(invoice.due_date).to eq('2017-11-30')
14+
expect(invoice.status).to eq('pending')
1515
expect(invoice.total_cents).to eq(9900)
16-
expect(invoice.payable_with).to eq("credit_card")
16+
expect(invoice.payable_with).to eq('credit_card')
1717
end
1818
end
1919

20-
describe ".fetch" do
20+
describe '.fetch' do
2121
it 'should return invoices', :vcr do
2222
invoices = Iugu::Invoice.fetch
2323

2424
expect(invoices.total).to eq(5)
2525
end
2626

2727
it 'should return invoice', :vcr do
28-
invoice = Iugu::Invoice.fetch(id: "3F14349B01264947A3765A79B1DEA1B4")
28+
invoice = Iugu::Invoice.fetch(id: '3F14349B01264947A3765A79B1DEA1B4')
2929

30-
expect(invoice.email).to eq("[email protected]")
31-
expect(invoice.due_date).to eq("2017-11-30")
32-
expect(invoice.status).to eq("pending")
30+
expect(invoice.email).to eq('[email protected]')
31+
expect(invoice.due_date).to eq('2017-11-30')
32+
expect(invoice.status).to eq('pending')
3333
expect(invoice.total_cents).to eq(9900)
34-
expect(invoice.payable_with).to eq("credit_card")
34+
expect(invoice.payable_with).to eq('credit_card')
3535
end
3636
end
3737
end

0 commit comments

Comments
 (0)