pagseguro-oficial 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.md +17 -1
  4. data/Gemfile +0 -2
  5. data/README.md +1 -1
  6. data/docs/transparent_checkout.md +3 -3
  7. data/examples/authorization/create_authorization.rb +32 -0
  8. data/examples/authorization/create_authorization_with_account.rb +56 -0
  9. data/examples/authorization/{authorization_by_code.rb → search/search_authorization_by_code.rb} +4 -4
  10. data/examples/authorization/search/search_authorization_by_date.rb +35 -0
  11. data/examples/authorization/{authorization_by_notification_code.rb → search/search_authorization_by_notification_code.rb} +4 -5
  12. data/examples/authorization/search/search_authorization_by_reference.rb +31 -0
  13. data/examples/{payment_request.rb → checkout/create_payment_request.rb} +5 -7
  14. data/examples/{transaction/abandoned_transactions.rb → checkout/search/search_abandoned_transactions.rb} +6 -3
  15. data/examples/{transaction/transaction_by_code.rb → checkout/search/search_transaction_by_code.rb} +3 -3
  16. data/examples/{transaction/transaction_by_notification_code.rb → checkout/search/search_transaction_by_notification_code.rb} +3 -3
  17. data/examples/{transaction/transaction_by_reference.rb → checkout/search/search_transaction_by_reference.rb} +3 -3
  18. data/examples/{transaction/transaction_status_history.rb → checkout/search/search_transaction_status_history.rb} +2 -2
  19. data/examples/{transaction/transactions_by_date.rb → checkout/search/search_transactions_by_date.rb} +3 -3
  20. data/examples/{transaction/boleto_transaction_request.rb → direct/create_transaction_using_boleto.rb} +1 -1
  21. data/examples/{transaction/credit_card_transaction_request.rb → direct/create_transaction_using_credit_card.rb} +1 -1
  22. data/examples/{transaction/online_debit_transaction.rb → direct/create_transaction_using_online_debit.rb} +1 -1
  23. data/examples/{installment.rb → get_installments.rb} +3 -3
  24. data/examples/{transaction/transaction_cancellation.rb → request_transaction_cancellation.rb} +2 -2
  25. data/examples/{authorization/authorization.rb → split_payment/create_authorization.rb} +5 -4
  26. data/examples/split_payment/create_payment_request.rb +71 -0
  27. data/lib/pagseguro.rb +14 -8
  28. data/lib/pagseguro/account.rb +29 -0
  29. data/lib/pagseguro/authorization.rb +10 -4
  30. data/lib/pagseguro/authorization/collection.rb +3 -1
  31. data/lib/pagseguro/authorization/request_serializer.rb +6 -6
  32. data/lib/pagseguro/authorization/response.rb +2 -2
  33. data/lib/pagseguro/authorization_request.rb +16 -4
  34. data/lib/pagseguro/authorization_request/request_serializer.rb +127 -15
  35. data/lib/pagseguro/authorization_request/response.rb +2 -2
  36. data/lib/pagseguro/company.rb +41 -0
  37. data/lib/pagseguro/document.rb +4 -0
  38. data/lib/pagseguro/documents.rb +5 -0
  39. data/lib/pagseguro/errors.rb +27 -5
  40. data/lib/pagseguro/extensions/collection_object.rb +34 -0
  41. data/lib/pagseguro/item.rb +4 -0
  42. data/lib/pagseguro/items.rb +10 -17
  43. data/lib/pagseguro/partner.rb +20 -0
  44. data/lib/pagseguro/payment_request.rb +30 -2
  45. data/lib/pagseguro/payment_request/{serializer.rb → request_serializer.rb} +86 -1
  46. data/lib/pagseguro/person.rb +40 -0
  47. data/lib/pagseguro/phone.rb +8 -0
  48. data/lib/pagseguro/phones.rb +5 -0
  49. data/lib/pagseguro/receiver.rb +17 -0
  50. data/lib/pagseguro/receiver_split.rb +15 -0
  51. data/lib/pagseguro/request.rb +25 -1
  52. data/lib/pagseguro/transaction.rb +7 -5
  53. data/lib/pagseguro/transaction_cancellation.rb +3 -6
  54. data/lib/pagseguro/transaction_cancellation/response.rb +7 -6
  55. data/lib/pagseguro/{refund.rb → transaction_refund.rb} +2 -2
  56. data/lib/pagseguro/{refund → transaction_refund}/request_serializer.rb +1 -1
  57. data/lib/pagseguro/{refund → transaction_refund}/response.rb +9 -9
  58. data/lib/pagseguro/{refund → transaction_refund}/response_serializer.rb +1 -1
  59. data/lib/pagseguro/transaction_request.rb +1 -4
  60. data/lib/pagseguro/transaction_request/response.rb +8 -7
  61. data/lib/pagseguro/version.rb +1 -1
  62. data/locales/pt-BR.yml +1 -0
  63. data/pagseguro-oficial.gemspec +13 -13
  64. data/spec/fixtures/authorization/search_authorization.xml +47 -0
  65. data/spec/fixtures/authorization_request/authorization_request.xml +11 -0
  66. data/spec/fixtures/authorization_request/authorization_request_with_account.xml +47 -0
  67. data/spec/pagseguro/account_spec.rb +27 -0
  68. data/spec/pagseguro/authorization/collection_spec.rb +3 -3
  69. data/spec/pagseguro/authorization/request_serializer_spec.rb +1 -2
  70. data/spec/pagseguro/authorization/response_spec.rb +70 -15
  71. data/spec/pagseguro/authorization_request/request_serializer_spec.rb +314 -14
  72. data/spec/pagseguro/authorization_request_spec.rb +96 -31
  73. data/spec/pagseguro/authorization_spec.rb +52 -10
  74. data/spec/pagseguro/company_spec.rb +12 -0
  75. data/spec/pagseguro/documents_spec.rb +37 -0
  76. data/spec/pagseguro/errors_spec.rb +45 -6
  77. data/spec/pagseguro/extensions/collection_object_spec.rb +77 -0
  78. data/spec/pagseguro/features/create_transaction_request_spec.rb +2 -2
  79. data/spec/pagseguro/installment/response_spec.rb +5 -3
  80. data/spec/pagseguro/installment_spec.rb +5 -2
  81. data/spec/pagseguro/items_spec.rb +104 -12
  82. data/spec/pagseguro/pagseguro_spec.rb +8 -8
  83. data/spec/pagseguro/partner_spec.rb +8 -0
  84. data/spec/pagseguro/payment_request/request_serializer_spec.rb +251 -0
  85. data/spec/pagseguro/payment_request_spec.rb +67 -11
  86. data/spec/pagseguro/person_spec.rb +10 -0
  87. data/spec/pagseguro/phones_spec.rb +38 -0
  88. data/spec/pagseguro/receiver_spec.rb +6 -0
  89. data/spec/pagseguro/receiver_split_spec.rb +7 -0
  90. data/spec/pagseguro/request_spec.rb +27 -4
  91. data/spec/pagseguro/session/response_spec.rb +6 -2
  92. data/spec/pagseguro/session_spec.rb +5 -2
  93. data/spec/pagseguro/transaction/response_spec.rb +14 -8
  94. data/spec/pagseguro/transaction/search_spec.rb +15 -8
  95. data/spec/pagseguro/transaction_cancellation/response_spec.rb +6 -3
  96. data/spec/pagseguro/transaction_cancellation_spec.rb +7 -5
  97. data/spec/pagseguro/{refund → transaction_refund}/request_serializer_spec.rb +3 -3
  98. data/spec/pagseguro/{refund → transaction_refund}/response_serializer_spec.rb +1 -1
  99. data/spec/pagseguro/{refund → transaction_refund}/response_spec.rb +3 -3
  100. data/spec/pagseguro/{refund_spec.rb → transaction_refund_spec.rb} +15 -7
  101. data/spec/pagseguro/transaction_request/request_serializer_spec.rb +9 -9
  102. data/spec/pagseguro/transaction_request/response_spec.rb +5 -2
  103. data/spec/pagseguro/transaction_request_spec.rb +14 -9
  104. data/spec/pagseguro/transaction_spec.rb +37 -30
  105. data/spec/spec_helper.rb +0 -3
  106. data/spec/support/ensure_type_macro.rb +20 -2
  107. data/{examples/refund.rb → transaction/transaction_refund.rb} +1 -1
  108. metadata +112 -96
  109. data/examples/transaction/invalid_transaction_by_notification_code.rb +0 -22
  110. data/lib/pagseguro/refund/serializer.rb +0 -24
  111. data/lib/pagseguro/transaction_cancellation/serializer.rb +0 -18
  112. data/spec/pagseguro/payment_request/serializer_spec.rb +0 -166
  113. data/spec/pagseguro/refund/serializer_spec.rb +0 -15
  114. data/spec/pagseguro/transaction_cancellation/serializer_spec.rb +0 -13
@@ -1,6 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe PagSeguro::PaymentRequest do
4
+ it_assigns_attribute :primary_receiver
4
5
  it_assigns_attribute :currency
5
6
  it_assigns_attribute :redirect_url
6
7
  it_assigns_attribute :extra_amount
@@ -20,6 +21,61 @@ describe PagSeguro::PaymentRequest do
20
21
  expect(payment.sender).to eql(sender)
21
22
  end
22
23
 
24
+ describe '#register split payment' do
25
+ before do
26
+ FakeWeb.register_uri(
27
+ :post,
28
+ 'https://ws.pagseguro.uol.com.br/v2/checkouts?appId=id&appKey=key',
29
+ body: ""
30
+ )
31
+ end
32
+
33
+
34
+ let(:subject) do
35
+ PagSeguro::PaymentRequest.new(
36
+ receivers: receivers,
37
+ credentials: credentials,
38
+ primary_receiver: 'primary@example.com',
39
+ sender: sender
40
+ )
41
+ end
42
+
43
+ let(:credentials) do
44
+ PagSeguro::ApplicationCredentials.new('id', 'key')
45
+ end
46
+
47
+ let(:sender) do
48
+ PagSeguro::Sender.new(phone: PagSeguro::Phone.new(area_code: 1, number: 2345))
49
+ end
50
+
51
+ let(:receivers) do
52
+ [
53
+ { email: 'a@example.com', split: { amount: 1 } },
54
+ { email: 'b@example.com', split: { amount: 1 } }
55
+ ]
56
+ end
57
+
58
+ context 'ensure receivers' do
59
+ it 'are PagSeguro::Receiver' do
60
+ subject.receivers.each do |receiver|
61
+ expect(receiver).to be_a(PagSeguro::Receiver)
62
+ end
63
+ end
64
+
65
+ it 'have correct keys' do
66
+ expect(subject.receivers[0].email).to eq 'a@example.com'
67
+ end
68
+ end
69
+
70
+ it "changes url to checkouts" do
71
+ expect(PagSeguro::Request).to receive(:post_xml).with(
72
+ 'checkouts', 'v2', credentials, a_string_matching(/<checkout>/)
73
+ )
74
+
75
+ subject.register
76
+ end
77
+ end
78
+
23
79
  it "sets the items" do
24
80
  payment = PagSeguro::PaymentRequest.new
25
81
  expect(payment.items).to be_a(PagSeguro::Items)
@@ -35,8 +91,8 @@ describe PagSeguro::PaymentRequest do
35
91
  before { FakeWeb.register_uri :any, %r[.*?], body: "" }
36
92
 
37
93
  it "serializes payment request" do
38
- PagSeguro::PaymentRequest::Serializer
39
- .should_receive(:new)
94
+ allow_any_instance_of(PagSeguro::PaymentRequest::RequestSerializer)
95
+ .to receive(:new)
40
96
  .with(payment)
41
97
  .and_return(double.as_null_object)
42
98
 
@@ -44,12 +100,12 @@ describe PagSeguro::PaymentRequest do
44
100
  end
45
101
 
46
102
  it "performs request" do
47
- params = double
103
+ params = double(:Params)
48
104
 
49
- PagSeguro::PaymentRequest::Serializer.any_instance.stub to_params: params
105
+ allow_any_instance_of(PagSeguro::PaymentRequest::RequestSerializer).to receive(:to_params).and_return(params)
50
106
 
51
- PagSeguro::Request
52
- .should_receive(:post)
107
+ expect(PagSeguro::Request)
108
+ .to receive(:post)
53
109
  .with("checkout", "v2", params)
54
110
 
55
111
  payment.register
@@ -57,10 +113,10 @@ describe PagSeguro::PaymentRequest do
57
113
 
58
114
  it "initializes response" do
59
115
  response = double
60
- PagSeguro::Request.stub post: response
116
+ allow(PagSeguro::Request).to receive(:post).and_return(response)
61
117
 
62
- PagSeguro::PaymentRequest::Response
63
- .should_receive(:new)
118
+ expect(PagSeguro::PaymentRequest::Response)
119
+ .to receive(:new)
64
120
  .with(response)
65
121
 
66
122
  payment.register
@@ -68,7 +124,7 @@ describe PagSeguro::PaymentRequest do
68
124
 
69
125
  it "returns response" do
70
126
  response = double
71
- PagSeguro::PaymentRequest::Response.stub new: response
127
+ allow(PagSeguro::PaymentRequest::Response).to receive(:new).and_return(response)
72
128
 
73
129
  expect(payment.register).to eql(response)
74
130
  end
@@ -76,7 +132,7 @@ describe PagSeguro::PaymentRequest do
76
132
 
77
133
  describe "#extra_params" do
78
134
  it "is empty before initialization" do
79
- expect(subject.extra_params).to eql([])
135
+ expect(subject.extra_params).to be_empty
80
136
  end
81
137
 
82
138
  it "allows extra parameter addition" do
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe PagSeguro::Person do
4
+ it_assigns_attribute :name
5
+ it_assigns_attribute :birth_date
6
+
7
+ it_ensures_type PagSeguro::Address, :address
8
+ it_ensures_collection_type PagSeguro::Document, :documents, [{type: 'CPF', value: 12312312312}]
9
+ it_ensures_collection_type PagSeguro::Phone, :phones, [{type: 'HOME', area_code: 11, number: 12312312312}]
10
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe PagSeguro::Phones do
4
+ [
5
+ :size,
6
+ :clear,
7
+ :empty?,
8
+ :any?,
9
+ :each,
10
+ :map
11
+ ].each do |method|
12
+ it { is_expected.to respond_to(method) }
13
+ end
14
+
15
+ it 'should initialize empty' do
16
+ expect(subject).to be_empty
17
+ end
18
+
19
+ context 'adding a new phone' do
20
+ let(:phone) { { type: 'HOME', area_code: 11, number: 11112222 } }
21
+
22
+ it "shouldn't add the same phone" do
23
+ subject << phone
24
+ expect{ subject << phone }.to_not change{ subject.size }
25
+ end
26
+
27
+ context 'ensures type the new phone' do
28
+ it 'can be a hash' do
29
+ expect{ subject << phone }.to change{ subject.size }.to(1)
30
+ end
31
+
32
+ it 'can be a PagSeguro::Phone' do
33
+ phone = PagSeguro::Phone.new(type: 'MOBILE', area_code: 11, number: 22221111)
34
+ expect{ subject << phone }.to change{ subject.size }.to(1)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,6 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::Receiver do
4
+ it_assigns_attribute :email
5
+ it_ensures_type PagSeguro::ReceiverSplit, :split
6
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::ReceiverSplit do
4
+ it_assigns_attribute :amount
5
+ it_assigns_attribute :rate_percent
6
+ it_assigns_attribute :fee_percent
7
+ end
@@ -14,16 +14,16 @@ describe PagSeguro::Request do
14
14
  end
15
15
 
16
16
  it "includes credentials" do
17
- PagSeguro.email = "EMAIL"
18
- PagSeguro.token = "TOKEN"
17
+ PagSeguro.configuration.email = "EMAIL"
18
+ PagSeguro.configuration.token = "TOKEN"
19
19
  PagSeguro::Request.post("checkout", "v3")
20
20
 
21
21
  expect(FakeWeb.last_request.body).to include("email=EMAIL&token=TOKEN")
22
22
  end
23
23
 
24
24
  it "includes custom credentials" do
25
- PagSeguro.email = "EMAIL"
26
- PagSeguro.token = "TOKEN"
25
+ PagSeguro.configuration.email = "EMAIL"
26
+ PagSeguro.configuration.token = "TOKEN"
27
27
  PagSeguro::Request.post("checkout", "v3", email: 'foo', token: 'bar')
28
28
 
29
29
  expect(FakeWeb.last_request.body).to include("email=foo&token=bar")
@@ -43,6 +43,29 @@ describe PagSeguro::Request do
43
43
  expect(request["lib-description"]).to be
44
44
  expect(request["language-engine-description"]).to be
45
45
  end
46
+
47
+ context "when POST request with XML data" do
48
+ let(:credentials) { PagSeguro::ApplicationCredentials.new('app123', 'key123') }
49
+ let(:xml) { File.read('./spec/fixtures/authorization_request/authorization_request.xml') }
50
+
51
+ before do
52
+ PagSeguro::Request.post_xml('authorizations/request', 'v2', credentials, xml)
53
+ end
54
+
55
+ let(:request) { FakeWeb.last_request }
56
+
57
+ it 'include request headers' do
58
+ expect(request["Content-Type"]).to eq "application/xml; charset=#{PagSeguro.encoding}"
59
+ end
60
+
61
+ it 'include data xml' do
62
+ expect(request.body).to eq xml
63
+ end
64
+
65
+ it 'correct url' do
66
+ expect(request.path).to eq '/v2/authorizations/request?appId=app123&appKey=key123'
67
+ end
68
+ end
46
69
  end
47
70
 
48
71
  context "GET request" do
@@ -40,9 +40,13 @@ RSpec.describe PagSeguro::Session::Response do
40
40
 
41
41
  context "when request fails" do
42
42
  before do
43
- allow(http_response).to receive(:success?).and_return(false)
44
- allow(http_response).to receive(:bad_request?).and_return(true)
43
+ allow(http_response).to receive_messages(
44
+ success?: false,
45
+ error?: true,
46
+ error: Aitch::BadRequestError
47
+ )
45
48
  end
49
+
46
50
  let(:raw_xml) { File.read("./spec/fixtures/invalid_code.xml") }
47
51
 
48
52
  it "change session errors" do
@@ -25,8 +25,11 @@ describe PagSeguro::Session do |variable|
25
25
 
26
26
  context "when request fails" do
27
27
  before do
28
- allow(request).to receive(:success?).and_return(false)
29
- allow(request).to receive(:bad_request?).and_return(true)
28
+ allow(request).to receive_messages(
29
+ success?: false,
30
+ error?: true,
31
+ error: Aitch::BadRequestError
32
+ )
30
33
  end
31
34
  let(:raw_xml) { File.read("./spec/fixtures/invalid_code.xml") }
32
35
 
@@ -38,11 +38,14 @@ describe PagSeguro::Transaction::Response do
38
38
 
39
39
  context "when request fails" do
40
40
  before do
41
- allow(http_response).to receive(:success?).and_return(false)
42
- allow(http_response).to receive(:bad_request?).and_return(true)
43
- allow(http_response).to receive(:not_found?).and_return(true)
44
- allow(http_response).to receive(:body).and_return(raw_xml)
41
+ allow(http_response).to receive_messages(
42
+ success?: false,
43
+ error?: true,
44
+ error: Aitch::NotFoundError,
45
+ body: raw_xml
46
+ )
45
47
  end
48
+
46
49
  let(:raw_xml) { File.read("./spec/fixtures/invalid_code.xml") }
47
50
 
48
51
  it "returns PagSeguro::Transaction::StatusCollection instance" do
@@ -77,11 +80,14 @@ describe PagSeguro::Transaction::Response do
77
80
 
78
81
  context "when request fails" do
79
82
  before do
80
- allow(http_response).to receive(:success?).and_return(false)
81
- allow(http_response).to receive(:bad_request?).and_return(true)
82
- allow(http_response).to receive(:not_found?).and_return(false)
83
- allow(http_response).to receive(:body).and_return(raw_xml)
83
+ allow(http_response).to receive_messages(
84
+ success?: false,
85
+ error?: true,
86
+ error: Aitch::BadRequestError,
87
+ body: raw_xml
88
+ )
84
89
  end
90
+
85
91
  let(:raw_xml) { File.read("./spec/fixtures/invalid_code.xml") }
86
92
 
87
93
  it "returns the transaction" do
@@ -4,7 +4,14 @@ describe PagSeguro::Search do
4
4
  let(:search) { PagSeguro::Search.new("foo", "bar", 1) }
5
5
  let(:source) { File.read("./spec/fixtures/transactions/search.xml") }
6
6
  let(:xml) { Nokogiri::XML(source) }
7
- let(:response) { double(:response, data: xml, unauthorized?: false, bad_request?: false, not_found?: false) }
7
+ let(:response) do
8
+ double(
9
+ :response,
10
+ data: xml,
11
+ error?: false,
12
+ error: nil
13
+ )
14
+ end
8
15
 
9
16
  context 'when being initialized' do
10
17
  it 'initializes with passed page number' do
@@ -57,19 +64,19 @@ describe PagSeguro::Search do
57
64
  context 'when there is a next page' do
58
65
  search = PagSeguro::Search.new('foo', 'bar', 0)
59
66
  it 'is page 0' do
60
- expect(search.next_page?).to be_truthy
67
+ expect(search).to be_next_page
61
68
  end
62
69
 
63
70
  it 'is not page 0, but page < total_pages' do
64
71
  allow(search).to receive(:total_pages).and_return(3)
65
- expect(search.next_page?).to be_truthy
72
+ expect(search).to be_next_page
66
73
  end
67
74
  end
68
75
 
69
76
  context 'when there is no next page' do
70
77
  it 'is not page 0, but page == total_pages' do
71
78
  allow(search).to receive(:total_pages).and_return(1)
72
- expect(search.next_page?).to be_falsy
79
+ expect(search).not_to be_next_page
73
80
  end
74
81
  end
75
82
  end
@@ -77,11 +84,11 @@ describe PagSeguro::Search do
77
84
  describe '#previous_page?' do
78
85
  context 'when there is a previous page' do
79
86
  search = PagSeguro::Search.new('foo', 'bar', 2)
80
- it { expect(search.previous_page?).to be_truthy }
87
+ it { expect(search).to be_previous_page }
81
88
  end
82
89
 
83
90
  context 'when there is no previous page' do
84
- it { expect(search.previous_page?).to be_falsy }
91
+ it { expect(search).not_to be_previous_page }
85
92
  end
86
93
  end
87
94
 
@@ -115,12 +122,12 @@ describe PagSeguro::Search do
115
122
  describe '#valid?' do
116
123
  it 'is valid' do
117
124
  allow(search).to receive(:fetch).and_return(true)
118
- expect(search.valid?).to be_truthy
125
+ expect(search).to be_valid
119
126
  end
120
127
 
121
128
  it "isn't valid" do
122
129
  allow(search).to receive(:fetch).and_return(false)
123
- expect(search.valid?).to be_falsy
130
+ expect(search).not_to be_valid
124
131
  end
125
132
  end
126
133
  end
@@ -24,9 +24,12 @@ describe PagSeguro::TransactionCancellation::Response do
24
24
 
25
25
  context "when request fails" do
26
26
  before do
27
- allow(http_response).to receive(:success?).and_return(false)
28
- allow(http_response).to receive(:bad_request?).and_return(true)
29
- allow(http_response).to receive(:body).and_return(raw_xml)
27
+ allow(http_response).to receive_messages(
28
+ success?: false,
29
+ error?: true,
30
+ error: Aitch::BadRequestError,
31
+ body: raw_xml
32
+ )
30
33
  end
31
34
  let(:raw_xml) { File.read("./spec/fixtures/invalid_code.xml") }
32
35
 
@@ -20,8 +20,8 @@ describe PagSeguro::TransactionCancellation do
20
20
  context "when request succeds" do
21
21
  let(:raw_xml) { File.read("./spec/fixtures/transaction_cancellation/success.xml") }
22
22
 
23
- it "returns boolean" do
24
- expect(subject.register).to be_truthy
23
+ it "returns a PagSeguro::TransactionCancellation" do
24
+ expect(subject.register).to be_a_kind_of PagSeguro::TransactionCancellation
25
25
  end
26
26
 
27
27
  it "does not add errors" do
@@ -35,9 +35,11 @@ describe PagSeguro::TransactionCancellation do
35
35
 
36
36
  context "when request fails" do
37
37
  before do
38
- allow(http_request).to receive(:success?).and_return(false)
39
- allow(http_request).to receive(:bad_request?).and_return(true)
40
- allow(http_request).to receive(:not_found?).and_return(false)
38
+ allow(http_request).to receive_messages(
39
+ success?: false,
40
+ error?: true,
41
+ error: Aitch::BadRequestError
42
+ )
41
43
  end
42
44
 
43
45
  let(:raw_xml) { File.read("./spec/fixtures/invalid_code.xml") }
@@ -1,10 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
- describe PagSeguro::Refund::RequestSerializer do
4
- subject(:serializer) { PagSeguro::Refund::RequestSerializer.new(refund) }
3
+ describe PagSeguro::TransactionRefund::RequestSerializer do
4
+ subject(:serializer) { PagSeguro::TransactionRefund::RequestSerializer.new(refund) }
5
5
 
6
6
  let(:refund) do
7
- PagSeguro::Refund.new transaction_code: "1234",
7
+ PagSeguro::TransactionRefund.new transaction_code: "1234",
8
8
  value: "100.50"
9
9
  end
10
10
 
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe PagSeguro::Refund::ResponseSerializer do
3
+ describe PagSeguro::TransactionRefund::ResponseSerializer do
4
4
  context "for existing refund response" do
5
5
  let(:source) { File.read("./spec/fixtures/refund/success.xml") }
6
6
  let(:xml) { Nokogiri::XML(source) }