rents 1.0.2 → 1.0.3
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/lib/rents/currency.rb +2 -1
- data/lib/rents/version.rb +1 -1
- data/lib/rents.rb +1 -1
- data/spec/rents/currency_spec.rb +39 -15
- data/spec/rents/transaction_spec.rb +1 -1
- metadata +2 -3
- data/lib/ca-bundle.crt +0 -3894
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba844c2f33282b0f62eb32737e641fb0f76e2057
|
4
|
+
data.tar.gz: 7c9a893f91276ff429344bebda00947690c97005
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09825367acc551a0f2e12e6a289737563a4b4b9a230b2f5ffbd913e9e747c00df89d89d1654b473d84b8173f282a23a27c044010250cf2aff7236b0f2b544739
|
7
|
+
data.tar.gz: f0c9f052506ee89272d9da97b8570a72e3f861fa213a9034a25d2b3cc8e3f35535858f702a2dad12b0c125c7e123cbc76e9247f4ac3638b65ea3ef3eabaa766e
|
data/lib/rents/currency.rb
CHANGED
@@ -5,7 +5,8 @@ module Rents
|
|
5
5
|
def self.to_operator_str(amount)
|
6
6
|
# Check invalid entry
|
7
7
|
return nil if amount.nil?
|
8
|
-
|
8
|
+
return amount.to_s if amount.is_a?Integer
|
9
|
+
return amount if amount.is_a?(String) && (amount.index('.').nil? || amount.index(',').nil?)
|
9
10
|
|
10
11
|
# Convert from BigDecimal
|
11
12
|
if amount.is_a?BigDecimal
|
data/lib/rents/version.rb
CHANGED
data/lib/rents.rb
CHANGED
data/spec/rents/currency_spec.rb
CHANGED
@@ -1,31 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Rents::Currency do
|
4
|
-
describe
|
4
|
+
describe 'Operator Format value' do
|
5
5
|
# setup it vars to have the conversion tested, value: 1999 (nineteen ninety nine)
|
6
6
|
pt_br = '1.999,00'
|
7
7
|
en_us = '1,999.00'
|
8
|
+
non_formatted = '199900'
|
9
|
+
non_formatted_with_cents = '199933'
|
8
10
|
|
9
11
|
# Values expected
|
10
|
-
|
12
|
+
cents_expected = '55'
|
13
|
+
non_cents_expected = '00'
|
14
|
+
operator_value = non_formatted
|
15
|
+
integer_value = non_formatted.to_i
|
11
16
|
operator_expected_value = '199900'
|
12
|
-
integer_value = '199900'.to_i
|
13
17
|
decimal_value = BigDecimal.new '1999.00'
|
14
|
-
decimal_expected_value = BigDecimal.new '1999.00'
|
15
18
|
operator_with_cents = '300055' # R$ 3.000,55
|
16
|
-
|
17
|
-
|
19
|
+
decimal_expected_value = BigDecimal.new '1999.00'
|
20
|
+
|
21
|
+
|
22
|
+
# Float values
|
23
|
+
float_with_cents = 1000.55
|
24
|
+
float_without_cents = 1000.0
|
18
25
|
|
19
26
|
# Values Converted to operator format
|
27
|
+
non_cents_received = Rents::Currency.get_cents operator_value
|
28
|
+
decimal_converted = Rents::Currency.to_decimal operator_value
|
29
|
+
cents_received = Rents::Currency.get_cents operator_with_cents
|
20
30
|
pt_br_operator_converted = Rents::Currency.to_operator_str pt_br
|
21
31
|
en_us_operator_converted = Rents::Currency.to_operator_str en_us
|
22
|
-
decimal_converted = Rents::Currency.to_decimal operator_value
|
23
|
-
big_decimal_converted = Rents::Currency.to_operator_str decimal_value
|
24
32
|
integer_converted = Rents::Currency.to_operator_str integer_value
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
float_without_cents = 1000.0
|
33
|
+
big_decimal_converted = Rents::Currency.to_operator_str decimal_value
|
34
|
+
non_formatted_converted = Rents::Currency.to_operator_str non_formatted
|
35
|
+
non_formatted_with_cents_converted = Rents::Currency.to_operator_str non_formatted_with_cents
|
29
36
|
|
30
37
|
context 'Decimal to Operator' do
|
31
38
|
# Convert PT_BR
|
@@ -70,12 +77,29 @@ describe Rents::Currency do
|
|
70
77
|
# Convert from the operator to BigDecimal instance, like rails does/need
|
71
78
|
it 'should be the BigDecimal expected' do
|
72
79
|
expect(decimal_converted).to be_a BigDecimal
|
73
|
-
expect(decimal_converted).to be == decimal_expected_value
|
80
|
+
expect(decimal_converted).to be == decimal_expected_value.to_i
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'Non-formatted value to operator' do
|
85
|
+
context 'without cents' do
|
86
|
+
it 'must be the same as received' do
|
87
|
+
expect(non_formatted_converted).to be == non_formatted
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'cents must be the same' do
|
91
|
+
expect(Rents::Currency.get_cents(non_formatted_converted)).to be == Rents::Currency.get_cents(non_formatted)
|
92
|
+
end
|
74
93
|
end
|
75
94
|
|
76
|
-
|
77
|
-
|
95
|
+
context 'with cents' do
|
96
|
+
it 'must be the same as received' do
|
97
|
+
expect(non_formatted_with_cents_converted).to be == non_formatted_with_cents
|
98
|
+
end
|
78
99
|
|
100
|
+
it 'cents must be the same' do
|
101
|
+
expect(Rents::Currency.get_cents(non_formatted_with_cents_converted)).to be == Rents::Currency.get_cents(non_formatted_with_cents)
|
102
|
+
end
|
79
103
|
end
|
80
104
|
end
|
81
105
|
|
@@ -19,7 +19,7 @@ describe Rents::Transaction do
|
|
19
19
|
@api_status = Rents::Status.new
|
20
20
|
@page_transaction = Rents::Transaction.new({
|
21
21
|
card:{brand:'visa'},
|
22
|
-
amount: Random.rand(99999),
|
22
|
+
amount: Random.rand(99999), # The last 2 numbers are the cents
|
23
23
|
redirect_link: "#{@base_url}/api/redirect_receiver" # (* optional) used only for CieloPage
|
24
24
|
})
|
25
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilton Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -217,7 +217,6 @@ files:
|
|
217
217
|
- LICENSE.txt
|
218
218
|
- README.md
|
219
219
|
- Rakefile
|
220
|
-
- lib/ca-bundle.crt
|
221
220
|
- lib/generators/rents/install_generator.rb
|
222
221
|
- lib/generators/templates/rents.rb
|
223
222
|
- lib/rents.rb
|