pag_seguro 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +3 -2
- data/README.md +16 -0
- data/lib/pag_seguro.rb +1 -0
- data/lib/pag_seguro/checkout.xml.haml +2 -0
- data/lib/pag_seguro/notification.rb +1 -1
- data/lib/pag_seguro/payment.rb +14 -6
- data/lib/pag_seguro/query.rb +2 -2
- data/lib/pag_seguro/transaction.rb +4 -2
- data/lib/pag_seguro/url.rb +36 -0
- data/lib/pag_seguro/version.rb +1 -1
- data/spec/pag_seguro/checkout_xml_spec.rb +77 -72
- data/spec/pag_seguro/day_of_year_spec.rb +9 -9
- data/spec/pag_seguro/errors/invalid_data_spec.rb +1 -1
- data/spec/pag_seguro/errors/unauthorized_spec.rb +1 -1
- data/spec/pag_seguro/errors/unknown_error_spec.rb +1 -1
- data/spec/pag_seguro/integration/checkout_spec.rb +9 -9
- data/spec/pag_seguro/integration/config.yml +4 -4
- data/spec/pag_seguro/integration/notification_spec.rb +21 -21
- data/spec/pag_seguro/integration/query_spec.rb +23 -23
- data/spec/pag_seguro/item_spec.rb +44 -44
- data/spec/pag_seguro/notification_spec.rb +1 -1
- data/spec/pag_seguro/payment_method_spec.rb +8 -8
- data/spec/pag_seguro/payment_spec.rb +177 -160
- data/spec/pag_seguro/pre_approval_spec.rb +56 -56
- data/spec/pag_seguro/query_spec.rb +26 -24
- data/spec/pag_seguro/sender_spec.rb +10 -10
- data/spec/pag_seguro/shipping_spec.rb +13 -13
- data/spec/pag_seguro/url_spec.rb +53 -0
- data/spec/pag_seguro/version_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- data/spec/support/transaction_shared_examples.rb +186 -167
- metadata +20 -17
@@ -2,63 +2,63 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
4
|
describe PagSeguro::PreApproval do
|
5
|
-
it {
|
6
|
-
it {
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
5
|
+
it { is_expected.to have_attribute_accessor(:name) }
|
6
|
+
it { is_expected.to have_attribute_accessor(:details) }
|
7
|
+
it { is_expected.to have_attribute_accessor(:amount_per_payment) }
|
8
|
+
it { is_expected.to have_attribute_accessor(:period) }
|
9
|
+
it { is_expected.to have_attribute_accessor(:day_of_week) }
|
10
|
+
it { is_expected.to have_attribute_accessor(:day_of_month) }
|
11
|
+
it { is_expected.to have_attribute_accessor(:day_of_year) }
|
12
|
+
it { is_expected.to have_attribute_accessor(:initial_date) }
|
13
|
+
it { is_expected.to have_attribute_accessor(:final_date) }
|
14
|
+
it { is_expected.to have_attribute_accessor(:max_amount_per_period) }
|
15
|
+
it { is_expected.to have_attribute_accessor(:max_total_amount) }
|
16
|
+
it { is_expected.to have_attribute_accessor(:review_URL) }
|
17
|
+
|
18
|
+
it { is_expected.to validate_presence_of :name }
|
19
|
+
it { is_expected.to validate_presence_of :period }
|
20
|
+
it { is_expected.to validate_presence_of :final_date }
|
21
|
+
it { is_expected.to validate_presence_of :max_amount_per_period }
|
22
|
+
it { is_expected.to validate_presence_of :max_total_amount }
|
23
23
|
|
24
24
|
[:weekly, :monthly, :bimonthly, :trimonthly, :semiannually, :yearly].each do |period_type|
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
25
|
+
it { is_expected.to allow_value(period_type).for(:period) }
|
26
|
+
it { is_expected.to allow_value(period_type.to_s).for(:period) }
|
27
|
+
it { is_expected.to allow_value(period_type.to_s.upcase).for(:period) }
|
28
28
|
end
|
29
|
-
it {
|
29
|
+
it { is_expected.not_to allow_value(:some_other_period_type).for(:period) }
|
30
30
|
|
31
|
-
it {
|
32
|
-
it {
|
33
|
-
it {
|
34
|
-
it {
|
35
|
-
it {
|
31
|
+
it { is_expected.to allow_value( nil ).for(:initial_date) }
|
32
|
+
it { is_expected.not_to allow_value( Time.now - 10.minutes ).for(:initial_date) }
|
33
|
+
it { is_expected.to allow_value( Time.now ).for(:initial_date) }
|
34
|
+
it { is_expected.to allow_value( (PagSeguro::PreApproval::DATE_RANGE - 5.minutes).from_now ).for(:initial_date) }
|
35
|
+
it { is_expected.not_to allow_value( PagSeguro::PreApproval::DATE_RANGE.from_now + 5.minutes ).for(:initial_date) }
|
36
36
|
|
37
|
-
it {
|
38
|
-
it {
|
39
|
-
it {
|
40
|
-
it {
|
41
|
-
it {
|
37
|
+
it { is_expected.not_to allow_value( nil ).for(:final_date) }
|
38
|
+
it { is_expected.not_to allow_value( Time.now - 10.minutes ).for(:final_date) }
|
39
|
+
it { is_expected.to allow_value( Time.now ).for(:final_date) }
|
40
|
+
it { is_expected.to allow_value( (PagSeguro::PreApproval::DATE_RANGE - 5.minutes).from_now ).for(:final_date) }
|
41
|
+
it { is_expected.not_to allow_value( PagSeguro::PreApproval::DATE_RANGE.from_now + 5.minutes ).for(:final_date) }
|
42
42
|
|
43
43
|
context "with an initial date" do
|
44
44
|
subject { PagSeguro::PreApproval.new(initial_date: 5.days.from_now) }
|
45
45
|
|
46
|
-
it {
|
47
|
-
it {
|
48
|
-
it {
|
49
|
-
it {
|
50
|
-
it {
|
46
|
+
it { is_expected.not_to allow_value( nil ).for(:final_date) }
|
47
|
+
it { is_expected.not_to allow_value( Time.now - 10.minutes + 5.days ).for(:final_date) }
|
48
|
+
it { is_expected.to allow_value( Time.now + 5.days ).for(:final_date) }
|
49
|
+
it { is_expected.to allow_value( (PagSeguro::PreApproval::DATE_RANGE - 5.minutes + 5.days).from_now ).for(:final_date) }
|
50
|
+
it { is_expected.not_to allow_value( PagSeguro::PreApproval::DATE_RANGE.from_now + 5.minutes + 5.days ).for(:final_date) }
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "initialized with minimum attributes" do
|
54
54
|
subject{ build :minimum_pre_approval }
|
55
|
-
it {
|
55
|
+
it { is_expected.to be_valid }
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "initialized with attributes" do
|
59
59
|
subject{ build :pre_approval }
|
60
60
|
|
61
|
-
it {
|
61
|
+
it { is_expected.to be_valid }
|
62
62
|
its(:name){ should == "Super seguro para notebook" }
|
63
63
|
its(:details){ should == "Toda segunda feira será cobrado o valor de R$150,00 para o seguro do notebook" }
|
64
64
|
its(:amount_per_payment){ should == '150.00' }
|
@@ -71,43 +71,43 @@ describe PagSeguro::PreApproval do
|
|
71
71
|
context "weekly" do
|
72
72
|
subject{ build :weekly_pre_approval }
|
73
73
|
|
74
|
-
it {
|
74
|
+
it { is_expected.to ensure_inclusion_of(:day_of_week).in_array(%w(monday tuesday wednesday thursday friday saturday sunday)) }
|
75
75
|
|
76
76
|
its(:period){ should == 'weekly' }
|
77
77
|
its(:day_of_week){ should == 'monday' }
|
78
|
-
it {
|
79
|
-
it {
|
80
|
-
it {
|
78
|
+
it { is_expected.to be_weekly }
|
79
|
+
it { is_expected.not_to be_monthly }
|
80
|
+
it { is_expected.not_to be_yearly }
|
81
81
|
|
82
82
|
end
|
83
83
|
|
84
84
|
context "monthly" do
|
85
85
|
subject{ build :monthly_pre_approval }
|
86
86
|
|
87
|
-
it {
|
87
|
+
it { is_expected.to ensure_inclusion_of(:day_of_month).in_range(1..28) }
|
88
88
|
|
89
89
|
its(:period){ should == 'monthly' }
|
90
90
|
its(:day_of_month){ should == 3 }
|
91
|
-
it {
|
92
|
-
it {
|
93
|
-
it {
|
91
|
+
it { is_expected.not_to be_weekly }
|
92
|
+
it { is_expected.to be_monthly }
|
93
|
+
it { is_expected.not_to be_yearly }
|
94
94
|
end
|
95
95
|
|
96
96
|
context "yearly" do
|
97
97
|
subject{ build :yearly_pre_approval }
|
98
98
|
|
99
|
-
it {
|
100
|
-
it {
|
101
|
-
it {
|
102
|
-
it {
|
103
|
-
it {
|
104
|
-
it {
|
99
|
+
it { is_expected.to validate_presence_of(:day_of_year) }
|
100
|
+
it { is_expected.to allow_value('10-22').for(:day_of_year) }
|
101
|
+
it { is_expected.to allow_value('01-01').for(:day_of_year) }
|
102
|
+
it { is_expected.to allow_value(PagSeguro::DayOfYear.new(month: 1, day: 1)).for(:day_of_year) }
|
103
|
+
it { is_expected.not_to allow_value('1-1').for(:day_of_year) }
|
104
|
+
it { is_expected.not_to allow_value("10-22\nanything").for(:day_of_year) }
|
105
105
|
|
106
106
|
its(:period){ should == 'yearly' }
|
107
107
|
its(:day_of_year){ should == '03-01' }
|
108
|
-
it {
|
109
|
-
it {
|
110
|
-
it {
|
108
|
+
it { is_expected.not_to be_weekly }
|
109
|
+
it { is_expected.not_to be_monthly }
|
110
|
+
it { is_expected.to be_yearly }
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -6,7 +6,7 @@ describe PagSeguro::Query do
|
|
6
6
|
let(:transactions_xml){ File.open( File.expand_path( File.dirname(__FILE__) + '/../fixtures/transaction_history.xml') ) }
|
7
7
|
|
8
8
|
describe "instance" do
|
9
|
-
before { PagSeguro::Query.
|
9
|
+
before { allow_any_instance_of(PagSeguro::Query).to receive_messages(transaction_data: transaction_data) }
|
10
10
|
let(:transaction){ PagSeguro::Query.new("mail", "token", "trans_code") }
|
11
11
|
subject{ PagSeguro::Query }
|
12
12
|
|
@@ -21,8 +21,8 @@ describe PagSeguro::Query do
|
|
21
21
|
context "with abandoned set to false" do
|
22
22
|
it "should try to fetch transactions" do
|
23
23
|
params = double(:params)
|
24
|
-
PagSeguro::Query.
|
25
|
-
RestClient.
|
24
|
+
allow(PagSeguro::Query).to receive_messages(search_params: params)
|
25
|
+
expect(RestClient).to receive(:get).with("https://ws.pagseguro.uol.com.br/v2/transactions", params: params)
|
26
26
|
PagSeguro::Query.find "email", "token"
|
27
27
|
end
|
28
28
|
end
|
@@ -30,61 +30,63 @@ describe PagSeguro::Query do
|
|
30
30
|
context "with abandoned set to true" do
|
31
31
|
it "should try to fetch abandoned transactions" do
|
32
32
|
params = double(:params)
|
33
|
-
PagSeguro::Query.
|
34
|
-
RestClient.
|
33
|
+
allow(PagSeguro::Query).to receive_messages(search_params: params)
|
34
|
+
expect(RestClient).to receive(:get).with("https://ws.pagseguro.uol.com.br/v2/transactions/abandoned", params: params)
|
35
35
|
PagSeguro::Query.find "email", "token", abandoned: true
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
context "with a stubbed response" do
|
40
|
-
before { RestClient.
|
40
|
+
before { allow(RestClient).to receive_messages(get: transactions_xml) }
|
41
41
|
subject{ PagSeguro::Query.find "email", "token", options: true }
|
42
42
|
|
43
43
|
it "calls search_url with received options" do
|
44
|
-
PagSeguro::Query.
|
44
|
+
expect(PagSeguro::Query).to receive(:search_params).with("email", "token", {options: true})
|
45
45
|
PagSeguro::Query.find "email", "token", options: true
|
46
46
|
end
|
47
47
|
|
48
|
-
it{
|
49
|
-
it
|
50
|
-
|
48
|
+
it{ is_expected.to be_a Array }
|
49
|
+
it'has 2 transactions' do
|
50
|
+
expect(subject.size).to eq(2)
|
51
|
+
end
|
52
|
+
it("should have transaction ids"){ expect(subject.map(&:id)).to eq(["REF1234", "REF5678"]) }
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
56
|
describe "::search_params" do
|
55
|
-
it("returns an Hash"){ PagSeguro::Query.search_params("email", "token").
|
57
|
+
it("returns an Hash"){ expect(PagSeguro::Query.search_params("email", "token")).to be_a Hash }
|
56
58
|
|
57
59
|
context "with default options" do
|
58
60
|
let(:search_params) { PagSeguro::Query.search_params("email", "token") }
|
59
|
-
it { search_params.keys.
|
60
|
-
it { search_params.keys.
|
61
|
-
it { search_params[:finalDate].
|
62
|
-
it { search_params[:initialDate].
|
61
|
+
it { expect(search_params.keys).not_to include :maxPageResults }
|
62
|
+
it { expect(search_params.keys).not_to include :page }
|
63
|
+
it { expect(search_params[:finalDate]).to include Date.today.iso8601 }
|
64
|
+
it { expect(search_params[:initialDate]).to include Date.yesterday.iso8601 }
|
63
65
|
|
64
66
|
it "should call parse_dates" do
|
65
|
-
PagSeguro::Query.
|
67
|
+
expect(PagSeguro::Query).to receive(:parse_dates)
|
66
68
|
search_params
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
70
72
|
context "with page number set to 2" do
|
71
73
|
let(:search_params){ PagSeguro::Query.search_params("email", "token", page: 2) }
|
72
|
-
it { search_params[:page].
|
74
|
+
it { expect(search_params[:page]).to eq(2) }
|
73
75
|
end
|
74
76
|
|
75
77
|
context "with max_page_results set to 100" do
|
76
78
|
let(:search_params){ PagSeguro::Query.search_params("email", "token", max_page_results: 100) }
|
77
|
-
it { search_params[:maxPageResults].
|
79
|
+
it { expect(search_params[:maxPageResults]).to eq(100) }
|
78
80
|
end
|
79
81
|
|
80
82
|
context "with initial_date set to 20 days ago" do
|
81
83
|
let(:search_params){ PagSeguro::Query.search_params("email", "token", initial_date: 20.days.ago) }
|
82
|
-
it { search_params[:initialDate].
|
84
|
+
it { expect(search_params[:initialDate]).to include 20.days.ago.iso8601 }
|
83
85
|
end
|
84
86
|
|
85
87
|
context "with final_date set to 10 days ago" do
|
86
88
|
let(:search_params){ PagSeguro::Query.search_params("email", "token", initial_date: 20.days.ago, final_date: 10.days.ago) }
|
87
|
-
it { search_params[:finalDate].
|
89
|
+
it { expect(search_params[:finalDate]).to include 10.days.ago.iso8601 }
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
@@ -115,21 +117,21 @@ describe PagSeguro::Query do
|
|
115
117
|
|
116
118
|
context "first return argument" do
|
117
119
|
it "returns yesterday if no initial date was given" do
|
118
|
-
PagSeguro::Query.parse_dates.first.
|
120
|
+
expect(PagSeguro::Query.parse_dates.first).to eq((Time.now - 1.day).iso8601)
|
119
121
|
end
|
120
122
|
|
121
123
|
it "returns the initial date in iso8601 format if provided" do
|
122
|
-
PagSeguro::Query.parse_dates(initial_date: 3.days.ago).first.
|
124
|
+
expect(PagSeguro::Query.parse_dates(initial_date: 3.days.ago).first).to eq(3.days.ago.iso8601)
|
123
125
|
end
|
124
126
|
end
|
125
127
|
|
126
128
|
context "second return argument" do
|
127
129
|
it "returns initial_date + 1 day no final date was given" do
|
128
|
-
PagSeguro::Query.parse_dates(initial_date: 2.days.ago).last.
|
130
|
+
expect(PagSeguro::Query.parse_dates(initial_date: 2.days.ago).last).to eq(1.day.ago.iso8601)
|
129
131
|
end
|
130
132
|
|
131
133
|
it "returns the final date in iso8601 format if provided" do
|
132
|
-
PagSeguro::Query.parse_dates(initial_date: 3.days.ago, final_date: 2.days.ago).last.
|
134
|
+
expect(PagSeguro::Query.parse_dates(initial_date: 3.days.ago, final_date: 2.days.ago).last).to eq(2.days.ago.iso8601)
|
133
135
|
end
|
134
136
|
end
|
135
137
|
end
|
@@ -3,10 +3,10 @@ require "spec_helper"
|
|
3
3
|
|
4
4
|
describe PagSeguro::Sender do
|
5
5
|
context "instance" do
|
6
|
-
it {
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
6
|
+
it { is_expected.to have_attribute_accessor(:email) }
|
7
|
+
it { is_expected.to have_attribute_accessor(:name) }
|
8
|
+
it { is_expected.to have_attribute_accessor(:phone_ddd) }
|
9
|
+
it { is_expected.to have_attribute_accessor(:phone_number) }
|
10
10
|
|
11
11
|
context "initialized with all attributes" do
|
12
12
|
subject { PagSeguro::Sender.new attributes_for(:sender) }
|
@@ -23,37 +23,37 @@ describe PagSeguro::Sender do
|
|
23
23
|
|
24
24
|
context "with nil name" do
|
25
25
|
subject { build :sender, name: nil }
|
26
|
-
it {
|
26
|
+
it { is_expected.not_to be_a_valid_name }
|
27
27
|
its(:name){ should be_nil }
|
28
28
|
end
|
29
29
|
|
30
30
|
context "with name Joao" do
|
31
31
|
subject { build :sender, name: "Joao" }
|
32
|
-
it {
|
32
|
+
it { is_expected.not_to be_a_valid_name }
|
33
33
|
its(:name){ should be_nil }
|
34
34
|
end
|
35
35
|
|
36
36
|
context "with name Joao Paulo" do
|
37
37
|
subject { build :sender, name: "Joao Paulo" }
|
38
|
-
it {
|
38
|
+
it { is_expected.to be_a_valid_name }
|
39
39
|
its(:name){ should == "Joao Paulo" }
|
40
40
|
end
|
41
41
|
|
42
42
|
context "with name João Paulo" do
|
43
43
|
subject { build :sender, name: "João Paulo" }
|
44
|
-
it {
|
44
|
+
it { is_expected.to be_a_valid_name }
|
45
45
|
its(:name){ should == "João Paulo" }
|
46
46
|
end
|
47
47
|
|
48
48
|
context "with very big name" do
|
49
49
|
subject { build :sender, name: ("a" * 50)+" "+("b" * 10) }
|
50
|
-
it {
|
50
|
+
it { is_expected.to be_a_valid_name }
|
51
51
|
its(:name){ should == "a" * 50 }
|
52
52
|
end
|
53
53
|
|
54
54
|
context "with double spaces in name" do
|
55
55
|
subject { build :sender, name: "Stefano Benatti" }
|
56
|
-
it {
|
56
|
+
it { is_expected.to be_a_valid_name }
|
57
57
|
its(:name){ should == "Stefano Benatti" }
|
58
58
|
end
|
59
59
|
|
@@ -4,22 +4,22 @@ require "spec_helper"
|
|
4
4
|
describe PagSeguro::Shipping do
|
5
5
|
let(:shipping){ PagSeguro::Shipping.new }
|
6
6
|
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
7
|
+
it { is_expected.to have_attribute_accessor(:type) }
|
8
|
+
it { is_expected.to have_attribute_accessor(:state) }
|
9
|
+
it { is_expected.to have_attribute_accessor(:city) }
|
10
|
+
it { is_expected.to have_attribute_accessor(:postal_code) }
|
11
|
+
it { is_expected.to have_attribute_accessor(:district) }
|
12
|
+
it { is_expected.to have_attribute_accessor(:street) }
|
13
|
+
it { is_expected.to have_attribute_accessor(:number) }
|
14
|
+
it { is_expected.to have_attribute_accessor(:complement) }
|
15
|
+
it { is_expected.to have_attribute_accessor(:cost) }
|
16
16
|
|
17
17
|
its(:type){ should == PagSeguro::Shipping::UNIDENTIFIED }
|
18
18
|
|
19
19
|
describe "instance" do
|
20
20
|
subject{ build(:shipping) }
|
21
21
|
|
22
|
-
it {
|
22
|
+
it { is_expected.to be_valid }
|
23
23
|
its(:cost){ should == "12.13" }
|
24
24
|
its(:postal_code){ should == "05363000" }
|
25
25
|
|
@@ -30,17 +30,17 @@ describe PagSeguro::Shipping do
|
|
30
30
|
|
31
31
|
context "with type 1" do
|
32
32
|
subject{ build(:shipping, type: 1) }
|
33
|
-
it {
|
33
|
+
it { is_expected.to be_pac }
|
34
34
|
end
|
35
35
|
|
36
36
|
context "with type 2" do
|
37
37
|
subject{ build(:shipping, type: 2) }
|
38
|
-
it {
|
38
|
+
it { is_expected.to be_sedex }
|
39
39
|
end
|
40
40
|
|
41
41
|
context "with type 3" do
|
42
42
|
subject{ build(:shipping, type: 3) }
|
43
|
-
it {
|
43
|
+
it { is_expected.to be_unidentified }
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PagSeguro::Url do
|
4
|
+
|
5
|
+
it "has a default environment" do
|
6
|
+
expect(PagSeguro::Url.environment).to eq :production
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should change the environment" do
|
10
|
+
PagSeguro::Url.environment = :sandbox
|
11
|
+
expect(PagSeguro::Url.environment).to eq :sandbox
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".api_url" do
|
15
|
+
it "raises when environment has no endpoint" do
|
16
|
+
PagSeguro::Url.environment = :invalid
|
17
|
+
|
18
|
+
expect {
|
19
|
+
PagSeguro::Url.api_url("/")
|
20
|
+
}.to raise_exception(PagSeguro::Url::InvalidEnvironmentError)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns api url" do
|
24
|
+
PagSeguro::Url.environment = :production
|
25
|
+
expect(PagSeguro::Url.api_url("/some/path")).to eql("https://ws.pagseguro.uol.com.br/v2/some/path")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns sandbox api url" do
|
29
|
+
PagSeguro::Url.environment = :sandbox
|
30
|
+
expect(PagSeguro::Url.api_url("/some/path")).to eql("https://ws.sandbox.pagseguro.uol.com.br/v2/some/path")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".site_url" do
|
35
|
+
it "raises when environment has no endpoint" do
|
36
|
+
PagSeguro::Url.environment = :invalid
|
37
|
+
|
38
|
+
expect {
|
39
|
+
PagSeguro::Url.site_url("/")
|
40
|
+
}.to raise_exception(PagSeguro::Url::InvalidEnvironmentError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns site url" do
|
44
|
+
PagSeguro::Url.environment = :production
|
45
|
+
expect(PagSeguro::Url.site_url("/some/path")).to eql("https://pagseguro.uol.com.br/v2/some/path")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns sandbox site url" do
|
49
|
+
PagSeguro::Url.environment = :sandbox
|
50
|
+
expect(PagSeguro::Url.site_url("/some/path")).to eql("https://sandbox.pagseguro.uol.com.br/v2/some/path")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|