boletosimples 0.4.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +6 -14
- data/README.md +12 -54
- data/lib/boletosimples.rb +10 -6
- data/lib/boletosimples/configuration.rb +18 -33
- data/lib/boletosimples/last_request.rb +12 -9
- data/lib/boletosimples/middlewares/bearer.rb +12 -0
- data/lib/boletosimples/middlewares/last_request.rb +3 -1
- data/lib/boletosimples/middlewares/raise_error.rb +9 -2
- data/lib/boletosimples/middlewares/user_agent.rb +3 -1
- data/lib/boletosimples/resources/bank_billet.rb +5 -11
- data/lib/boletosimples/resources/bank_billet_account.rb +3 -1
- data/lib/boletosimples/resources/bank_billet_discharge.rb +6 -0
- data/lib/boletosimples/resources/bank_billet_payment.rb +6 -0
- data/lib/boletosimples/resources/bank_billet_remittance.rb +6 -0
- data/lib/boletosimples/resources/base_model.rb +3 -1
- data/lib/boletosimples/resources/customer.rb +3 -1
- data/lib/boletosimples/resources/customer_import.rb +8 -0
- data/lib/boletosimples/resources/customer_subscription.rb +3 -10
- data/lib/boletosimples/resources/customer_subscription_import.rb +8 -0
- data/lib/boletosimples/resources/discharge.rb +4 -11
- data/lib/boletosimples/resources/email_delivery.rb +6 -0
- data/lib/boletosimples/resources/event.rb +3 -1
- data/lib/boletosimples/resources/installment.rb +3 -1
- data/lib/boletosimples/resources/remittance.rb +3 -1
- data/lib/boletosimples/resources/sms_delivery.rb +6 -0
- data/lib/boletosimples/resources/transaction.rb +3 -1
- data/lib/boletosimples/resources/webhook.rb +3 -1
- data/lib/boletosimples/resources/webhook_delivery.rb +3 -1
- data/lib/boletosimples/response_error.rb +8 -3
- data/lib/boletosimples/version.rb +3 -1
- data/spec/boletosimples/configuration_spec.rb +71 -83
- data/spec/boletosimples/last_request_spec.rb +16 -28
- data/spec/boletosimples/resources/bank_billet_account_spec.rb +57 -33
- data/spec/boletosimples/resources/bank_billet_discharge_spec.rb +12 -0
- data/spec/boletosimples/resources/bank_billet_payment_spec.rb +12 -0
- data/spec/boletosimples/resources/bank_billet_remittance_spec.rb +12 -0
- data/spec/boletosimples/resources/bank_billet_spec.rb +56 -42
- data/spec/boletosimples/resources/customer_import_spec.rb +67 -0
- data/spec/boletosimples/resources/customer_spec.rb +52 -39
- data/spec/boletosimples/resources/customer_subscription_import_spec.rb +67 -0
- data/spec/boletosimples/resources/customer_subscription_spec.rb +61 -33
- data/spec/boletosimples/resources/discharge_spec.rb +64 -11
- data/spec/boletosimples/resources/email_delivery_spec.rb +12 -0
- data/spec/boletosimples/resources/event_spec.rb +7 -12
- data/spec/boletosimples/resources/installment_spec.rb +61 -32
- data/spec/boletosimples/resources/remittance_spec.rb +7 -12
- data/spec/boletosimples/resources/sms_delivery_spec.rb +12 -0
- data/spec/boletosimples/resources/transactions_spec.rb +7 -12
- data/spec/boletosimples/resources/webhook_delivery_spec.rb +7 -12
- data/spec/boletosimples/resources/webhook_spec.rb +7 -12
- data/spec/fixtures/customer_imports.csv +1 -0
- data/spec/fixtures/customer_subscription_imports.csv +1 -0
- data/spec/fixtures/discharge.RET +3 -0
- data/spec/fixtures/vcr_cassettes/last_request/bank_billets.yml +536 -88
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/all.yml +537 -91
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/cancel/success.yml +34 -92
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/create/invalid_params.yml +32 -20
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/create/invalid_root.yml +28 -17
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/create/valid.yml +43 -27
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/duplicate/success.yml +83 -0
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/find.yml +51 -27
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/all.yml +131 -20
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/create/invalid_params.yml +34 -20
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/create/invalid_root.yml +30 -19
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/create/valid.yml +41 -21
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/find.yml +38 -18
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_discharge/all.yml +97 -0
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_payment/all.yml +75 -0
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_remittance/all.yml +126 -0
- data/spec/fixtures/vcr_cassettes/resources/customer/all.yml +79 -32
- data/spec/fixtures/vcr_cassettes/resources/customer/create/invalid_params.yml +30 -17
- data/spec/fixtures/vcr_cassettes/resources/customer/create/invalid_root.yml +28 -17
- data/spec/fixtures/vcr_cassettes/resources/customer/create/valid.yml +33 -21
- data/spec/fixtures/vcr_cassettes/resources/customer/find.yml +33 -19
- data/spec/fixtures/vcr_cassettes/resources/customer_import/all.yml +74 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_import/create/invalid_params.yml +69 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_import/create/invalid_root.yml +69 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_import/create/valid.yml +76 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_import/find.yml +71 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/all.yml +102 -52
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/create/invalid_params.yml +40 -50
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/create/invalid_root.yml +36 -48
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/create/valid.yml +48 -53
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/find.yml +44 -50
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/next_charge.yml +45 -133
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/all.yml +75 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/create/invalid_params.yml +69 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/create/invalid_root.yml +70 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/create/valid.yml +76 -0
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/find.yml +71 -0
- data/spec/fixtures/vcr_cassettes/resources/discharge/all.yml +64 -33
- data/spec/fixtures/vcr_cassettes/resources/discharge/create/invalid_params.yml +70 -0
- data/spec/fixtures/vcr_cassettes/resources/discharge/create/invalid_root.yml +69 -0
- data/spec/fixtures/vcr_cassettes/resources/discharge/create/valid.yml +84 -0
- data/spec/fixtures/vcr_cassettes/resources/discharge/find.yml +71 -0
- data/spec/fixtures/vcr_cassettes/resources/email_delivery/all.yml +73 -0
- data/spec/fixtures/vcr_cassettes/resources/event/all.yml +490 -166
- data/spec/fixtures/vcr_cassettes/resources/installment/all.yml +418 -52
- data/spec/fixtures/vcr_cassettes/resources/installment/create/invalid_params.yml +41 -52
- data/spec/fixtures/vcr_cassettes/resources/installment/create/invalid_root.yml +36 -48
- data/spec/fixtures/vcr_cassettes/resources/installment/create/valid.yml +48 -53
- data/spec/fixtures/vcr_cassettes/resources/installment/find.yml +44 -52
- data/spec/fixtures/vcr_cassettes/resources/remittance/all.yml +53 -33
- data/spec/fixtures/vcr_cassettes/resources/sns_delivery/all.yml +73 -0
- data/spec/fixtures/vcr_cassettes/resources/transaction/all.yml +34 -22
- data/spec/fixtures/vcr_cassettes/resources/web_hook/all.yml +42 -33
- data/spec/fixtures/vcr_cassettes/resources/webhook_delivery/all.yml +1232 -54
- data/spec/spec_helper.rb +3 -20
- data/spec/support/stub_env.rb +7 -0
- data/spec/support/vcr.rb +3 -4
- metadata +190 -82
- data/.coveralls.yml +0 -2
- data/.gitignore +0 -19
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -11
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/boletosimples.gemspec +0 -37
- data/lib/boletosimples/extra.rb +0 -8
- data/lib/boletosimples/resources/partner/user.rb +0 -7
- data/lib/oauth2_patch.rb +0 -24
- data/spec/boletosimples/extra_spec.rb +0 -31
- data/spec/boletosimples/resources/partner/user_spec.rb +0 -19
- data/spec/fixtures/vcr_cassettes/configuration/client_credentials/invalid.yml +0 -64
- data/spec/fixtures/vcr_cassettes/configuration/client_credentials/valid.yml +0 -56
- data/spec/fixtures/vcr_cassettes/extra/userinfo/authenticated.yml +0 -58
- data/spec/fixtures/vcr_cassettes/extra/userinfo/not_authenticated.yml +0 -54
- data/spec/fixtures/vcr_cassettes/last_request/userinfo.yml +0 -58
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/cancel/failure.yml +0 -118
- data/spec/fixtures/vcr_cassettes/resources/partner/user/create.yml +0 -60
- data/spec/spec.opts +0 -8
@@ -1,14 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BoletoSimples
|
2
4
|
class CustomerSubscription < BaseModel
|
3
|
-
|
4
|
-
def next_charge
|
5
|
-
self.class.request(:_method => :post, :_path => self.class.build_request_path('customer_subscriptions/:id/next_charge', {self.class.primary_key => id})) do |parsed_data, response|
|
6
|
-
assign_attributes(self.class.parse(parsed_data[:data])) if parsed_data[:data].any?
|
7
|
-
@metadata = parsed_data[:metadata]
|
8
|
-
@response_errors = parsed_data[:errors]
|
9
|
-
@response = response
|
10
|
-
end
|
11
|
-
return @response.success?
|
12
|
-
end
|
5
|
+
custom_post :next_charge
|
13
6
|
end
|
14
7
|
end
|
@@ -1,14 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BoletoSimples
|
2
4
|
class Discharge < BaseModel
|
3
|
-
|
4
|
-
def pay_off
|
5
|
-
self.class.request(:_method => :put, :_path => self.class.build_request_path('discharges/:id/pay_off', {self.class.primary_key => id})) do |parsed_data, response|
|
6
|
-
assign_attributes(self.class.parse(parsed_data[:data])) if parsed_data[:data].any?
|
7
|
-
@metadata = parsed_data[:metadata]
|
8
|
-
@response_errors = parsed_data[:errors]
|
9
|
-
@response = response
|
10
|
-
end
|
11
|
-
return @response.success?
|
12
|
-
end
|
5
|
+
custom_put :pay_off
|
13
6
|
end
|
14
|
-
end
|
7
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BoletoSimples
|
2
4
|
# BoletoSimples::ResponseError
|
3
5
|
# Exception that gets raised if the response is an error (4xx or 5xx)
|
@@ -29,15 +31,18 @@ module BoletoSimples
|
|
29
31
|
@status = response[:status].to_i
|
30
32
|
@method = response[:method].to_s.upcase
|
31
33
|
@url = response[:url]
|
32
|
-
|
34
|
+
|
35
|
+
errors = response[:body][:errors]
|
36
|
+
@error_message = errors.first[:title] unless errors.blank?
|
33
37
|
|
34
38
|
super
|
35
39
|
end
|
36
40
|
|
37
41
|
def to_s
|
38
|
-
msg =
|
42
|
+
msg = ''
|
43
|
+
msg += "#{status} #{method} #{url}"
|
39
44
|
msg << " (#{error_message})" unless error_message.blank?
|
40
45
|
msg
|
41
46
|
end
|
42
47
|
end
|
43
|
-
end
|
48
|
+
end
|
@@ -1,84 +1,72 @@
|
|
1
|
-
#
|
2
|
-
require 'spec_helper'
|
1
|
+
# # frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
# Before running this spec again, you need to set environment variable BOLETOSIMPLES_APP_ID and BOLETOSIMPLES_APP_SECRET
|
75
|
-
before {
|
76
|
-
BoletoSimples.configure do |c|
|
77
|
-
c.access_token = nil
|
78
|
-
end
|
79
|
-
}
|
80
|
-
it { expect(subject.client_credentials).to include(:access_token) }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
3
|
+
# require 'spec_helper'
|
4
|
+
|
5
|
+
# RSpec.describe BoletoSimples::Configuration do
|
6
|
+
# describe 'defaults' do
|
7
|
+
# subject { described_class.new }
|
8
|
+
|
9
|
+
# before do
|
10
|
+
# stub_env('BOLETOSIMPLES_ENV', nil)
|
11
|
+
# stub_env('BOLETOSIMPLES_USER_AGENT', nil)
|
12
|
+
# subject.setup_her
|
13
|
+
# end
|
14
|
+
|
15
|
+
# it do
|
16
|
+
# expect(subject.environment).to eq(:sandbox)
|
17
|
+
# expect(subject.base_uri).to eq('https://sandbox.boletosimples.com.br/api/v1')
|
18
|
+
# expect(subject.cache).to be_nil
|
19
|
+
# expect(subject.user_agent).to be_nil
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
23
|
+
# describe 'environment variables' do
|
24
|
+
# subject { BoletoSimples.configuration }
|
25
|
+
|
26
|
+
# before do
|
27
|
+
# stub_env('BOLETOSIMPLES_ENV', 'production')
|
28
|
+
# stub_env('BOLETOSIMPLES_USER_AGENT', 'email@minhaempresa.com.br')
|
29
|
+
# BoletoSimples.configure
|
30
|
+
# end
|
31
|
+
|
32
|
+
# it do
|
33
|
+
# expect(subject.environment).to eq(:production)
|
34
|
+
# expect(subject.base_uri).to eq('https://boletosimples.com.br/api/v1')
|
35
|
+
# expect(subject.user_agent).to eq('email@minhaempresa.com.br')
|
36
|
+
# end
|
37
|
+
|
38
|
+
# describe 'cache' do
|
39
|
+
# it do
|
40
|
+
# expect(subject.cache).to be_nil
|
41
|
+
# expect(Her::API.default_api.connection.builder.handlers).not_to include(Faraday::HttpCache)
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
|
46
|
+
# describe 'configuration' do
|
47
|
+
# subject { BoletoSimples.configuration }
|
48
|
+
|
49
|
+
# let(:cache_object) { double('Dalli') }
|
50
|
+
|
51
|
+
# before do
|
52
|
+
# BoletoSimples.configure do |c|
|
53
|
+
# c.environment = :production
|
54
|
+
# c.cache = cache_object
|
55
|
+
# c.user_agent = 'Meu agent'
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
|
59
|
+
# it do
|
60
|
+
# expect(subject.environment).to eq(:production)
|
61
|
+
# expect(subject.user_agent).to eq('Meu agent')
|
62
|
+
# expect(subject.base_uri).to eq('https://boletosimples.com.br/api/v1')
|
63
|
+
# end
|
64
|
+
|
65
|
+
# describe 'cache' do
|
66
|
+
# it do
|
67
|
+
# expect(subject.cache).to eq(cache_object)
|
68
|
+
# expect(Her::API.default_api.connection.builder.handlers).to include(Faraday::HttpCache)
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
# end
|
@@ -1,34 +1,22 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
RSpec.describe BoletoSimples::LastRequest do
|
5
|
-
|
6
|
-
BoletoSimples.configure do |c|
|
7
|
-
c.application_id = nil
|
8
|
-
c.application_secret = nil
|
9
|
-
end
|
10
|
-
}
|
11
|
-
describe 'bank_billets', vcr: { cassette_name: 'last_request/bank_billets'} do
|
12
|
-
before { BoletoSimples::BankBillet.all.size }
|
13
|
-
subject { BoletoSimples.last_request }
|
14
|
-
it { expect(subject).to be_kind_of(BoletoSimples::LastRequest) }
|
15
|
-
it { expect(subject.body).to be_kind_of(Array) }
|
16
|
-
it { expect(subject.body.first).to be_kind_of(Hash) }
|
17
|
-
it { expect(subject.response_headers).to be_kind_of(Hash) }
|
18
|
-
it { expect(subject.total).to be_kind_of(Integer) }
|
19
|
-
it { expect(subject.ratelimit_limit).to be_kind_of(Integer) }
|
20
|
-
it { expect(subject.ratelimit_remaining).to be_kind_of(Integer) }
|
21
|
-
it { expect(subject.links.keys).to match_array([:next, :last]) }
|
22
|
-
end
|
23
|
-
describe 'user_info', vcr: { cassette_name: 'last_request/userinfo'} do
|
24
|
-
before { BoletoSimples::Extra.userinfo }
|
6
|
+
describe 'bank_billets', vcr: { cassette_name: 'last_request/bank_billets' } do
|
25
7
|
subject { BoletoSimples.last_request }
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
it
|
30
|
-
|
31
|
-
|
32
|
-
|
8
|
+
|
9
|
+
before { BoletoSimples::BankBillet.all(page: 2).size }
|
10
|
+
|
11
|
+
it do
|
12
|
+
expect(subject).to be_kind_of(described_class)
|
13
|
+
expect(subject.body).to be_kind_of(Array)
|
14
|
+
expect(subject.body.first).to be_kind_of(Hash)
|
15
|
+
expect(subject.response_headers).to be_kind_of(Hash)
|
16
|
+
expect(subject.total).to be_kind_of(Integer)
|
17
|
+
expect(subject.ratelimit_limit).to be_kind_of(Integer)
|
18
|
+
expect(subject.ratelimit_remaining).to be_kind_of(Integer)
|
19
|
+
expect(subject.links.keys).to match_array(%i[first next prev])
|
20
|
+
end
|
33
21
|
end
|
34
22
|
end
|
@@ -1,62 +1,86 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
# Before running this spec again, you need to set environment variable
|
5
|
+
# Before running this spec again, you need to set environment variable BOLETOSIMPLES_API_TOKEN
|
6
6
|
RSpec.describe BoletoSimples::BankBilletAccount do
|
7
|
-
before {
|
8
|
-
BoletoSimples.configure do |c|
|
9
|
-
c.application_id = nil
|
10
|
-
c.application_secret = nil
|
11
|
-
end
|
12
|
-
}
|
13
7
|
describe 'methods' do
|
14
|
-
before
|
8
|
+
before do
|
15
9
|
VCR.use_cassette('resources/bank_billet_account/create/valid') do
|
16
|
-
@bank_billet_account =
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
10
|
+
@bank_billet_account = described_class.create(
|
11
|
+
bank_contract_slug: 'sicoob-02',
|
12
|
+
next_our_number: '1',
|
13
|
+
agency_number: '4327',
|
14
|
+
agency_digit: '3',
|
15
|
+
account_number: '3666',
|
16
|
+
account_digit: '8',
|
17
|
+
extra1: '1234567',
|
18
|
+
beneficiary_name: 'XPTO S.A.',
|
19
|
+
beneficiary_cnpj_cpf: '22.622.867/0001-11',
|
20
|
+
beneficiary_address_street: 'Rua S',
|
21
|
+
beneficiary_address_city: 'São Paulo',
|
22
|
+
beneficiary_address_state: 'SP',
|
23
|
+
beneficiary_address_neighborhood: 'Moema',
|
24
|
+
beneficiary_address_zipcode: '04524030'
|
25
|
+
)
|
25
26
|
end
|
26
|
-
|
27
|
+
end
|
28
|
+
|
27
29
|
describe 'create' do
|
28
30
|
context 'valid parameters' do
|
29
31
|
subject { @bank_billet_account }
|
30
|
-
|
31
|
-
it
|
32
|
-
|
32
|
+
|
33
|
+
it do
|
34
|
+
expect(subject).to be_a_kind_of(described_class)
|
35
|
+
expect(subject.response_errors).to eq({})
|
36
|
+
end
|
33
37
|
end
|
38
|
+
|
34
39
|
context 'invalid parameters' do
|
35
40
|
context 'empty bank_billet' do
|
36
|
-
subject
|
41
|
+
subject do
|
37
42
|
VCR.use_cassette('resources/bank_billet_account/create/invalid_root') do
|
38
|
-
|
43
|
+
described_class.create({})
|
39
44
|
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it {
|
48
|
+
expect(subject.response_errors).to eq([{ code: 422, status: 422,
|
49
|
+
title: 'bank_billet_account não pode ficar em branco' }])
|
40
50
|
}
|
41
|
-
it { expect(subject.response_errors).to eq({ bank_billet_account: ["não pode ficar em branco"] }) }
|
42
51
|
end
|
52
|
+
|
43
53
|
context 'invalid params' do
|
44
|
-
subject
|
54
|
+
subject do
|
45
55
|
VCR.use_cassette('resources/bank_billet_account/create/invalid_params') do
|
46
|
-
|
56
|
+
described_class.create({ bank_contract_slug: '' })
|
47
57
|
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it {
|
61
|
+
expect(subject.response_errors).to eq({ bank_contract_slug: ['não pode ficar em branco'],
|
62
|
+
beneficiary_name: ['não pode ficar em branco'],
|
63
|
+
beneficiary_cnpj_cpf: ['não pode ficar em branco'],
|
64
|
+
beneficiary_address_street: ['não pode ficar em branco'],
|
65
|
+
beneficiary_address_city: ['não pode ficar em branco'],
|
66
|
+
beneficiary_address_neighborhood: ['não pode ficar em branco'],
|
67
|
+
beneficiary_address_state: ['não pode ficar em branco'],
|
68
|
+
beneficiary_address_zipcode: ['não pode ficar em branco'] })
|
48
69
|
}
|
49
|
-
it { expect(subject.response_errors).to eq({ :agency_number => ["não pode ficar em branco"], :account_number => ["não pode ficar em branco"], :bank_contract_slug => ["não pode ficar em branco"] }) }
|
50
70
|
end
|
51
71
|
end
|
52
72
|
end
|
73
|
+
|
53
74
|
describe 'find', vcr: { cassette_name: 'resources/bank_billet_account/find' } do
|
54
|
-
subject {
|
55
|
-
|
75
|
+
subject { described_class.find(@bank_billet_account.id) }
|
76
|
+
|
77
|
+
it { expect(subject).to be_a_kind_of(described_class) }
|
56
78
|
end
|
79
|
+
|
57
80
|
describe 'all', vcr: { cassette_name: 'resources/bank_billet_account/all' } do
|
58
|
-
subject {
|
59
|
-
|
81
|
+
subject { described_class.all }
|
82
|
+
|
83
|
+
it { expect(subject.first).to be_a_kind_of(described_class) }
|
60
84
|
end
|
61
85
|
end
|
62
|
-
end
|
86
|
+
end
|