rents 0.1.8 → 0.1.9
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 +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/lib/generators/rents/install_generator.rb +15 -0
- data/lib/generators/templates/rents.rb +35 -0
- data/lib/rents/connection.rb +9 -3
- data/lib/rents/currency.rb +65 -0
- data/lib/rents/hash.rb +0 -0
- data/lib/rents/status.rb +0 -0
- data/lib/rents/string.rb +13 -0
- data/lib/rents/transaction.rb +6 -1
- data/lib/rents/version.rb +1 -1
- data/lib/rents.rb +24 -1
- data/modelagem/Sequence - APIClient.asta +0 -0
- data/modelagem/Structure - ClassDiagram.asta +0 -0
- data/modelagem/WorkFlow - LocalGEM.asta +0 -0
- data/modelagem/WorkFlow - LocalGEM.png +0 -0
- data/modelagem/useful_files/card_operators/cielo/test_cards.txt +0 -0
- data/modelagem/useful_files/card_operators/cielo/test_keys.txt +0 -0
- data/rents.gemspec +8 -0
- data/spec/helpers.rb +0 -0
- data/spec/rents/conversions_spec.rb +36 -0
- data/spec/rents/currency_spec.rb +108 -0
- data/spec/rents/status_spec.rb +0 -0
- data/spec/rents/transaction_spec.rb +25 -17
- data/spec/spec_helper.rb +0 -0
- metadata +52 -4
- data/spec/rents/rents_spec.rb +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78f0ca2bdd14b5b3ec218b9c3058c738ba6d7874
|
|
4
|
+
data.tar.gz: 7ac12d3c2e9e29ea4c0c666481c54972bb7c51bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ea1faa458f68b72f6f6021337979d5d6f5a015329c7a87413c19179af4497ea1c7affa827224dcaccac9fcc18ffd55729df26599b5e232af4c1cc4dbf0801fb
|
|
7
|
+
data.tar.gz: 56293d94bfef00a16ad362be770130aaac44b34416884591be0b756483bd3aa9e7a4b7414aff308356cf6637b8455262932975debe468ffe0ec3e2850371832a
|
data/.gitignore
CHANGED
|
File without changes
|
data/Gemfile
CHANGED
|
File without changes
|
data/LICENSE.txt
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
File without changes
|
data/Rakefile
CHANGED
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Rents
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
source_root File.expand_path("../../templates", __FILE__)
|
|
5
|
+
|
|
6
|
+
desc "It automatically create it initializer RentS rails app config"
|
|
7
|
+
|
|
8
|
+
def copy_initializer
|
|
9
|
+
template "rents.rb", "config/initializers/rents.rb"
|
|
10
|
+
puts 'Check your config/initializers/rents.rb & read it comments'.colorize(:light_yellow)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
# TODO if using Rails 4 or greater use copy and paste on your secret.yml:
|
|
4
|
+
# rents:
|
|
5
|
+
# app_id: # TODO your app_id
|
|
6
|
+
# app_secret_key: # TODO your app_secret_key
|
|
7
|
+
# IMPORTANT: remember that test & development is not necessary if using test_env, but if you want your test app remember to use you test_app id & secret
|
|
8
|
+
|
|
9
|
+
# It automatic the RentS to it TestEnv & ProductionEnv
|
|
10
|
+
if Rails.env.development? || Rails.env.test?
|
|
11
|
+
# TODO if using Rails 3 or older & not using the TEST_ENV, put here your TEST app_id & your secret_key
|
|
12
|
+
Rents.app_id = ''
|
|
13
|
+
Rents.secret_key = ''
|
|
14
|
+
|
|
15
|
+
# TODO: Uncomment test_env if you want to test using RentS default & global app
|
|
16
|
+
# Rents.test_env = true
|
|
17
|
+
# TODO: Uncomment debugger if you have an RentS instance on your machine
|
|
18
|
+
# Rents.debugger = true
|
|
19
|
+
elsif Rails.env.production?
|
|
20
|
+
# TODO if using Rails 3 or older, put here your PRODUCTION app_id & your secret_key
|
|
21
|
+
Rents.app_id = ''
|
|
22
|
+
Rents.secret_key = ''
|
|
23
|
+
|
|
24
|
+
# For production remember to keep it false or just remove it
|
|
25
|
+
Rents.test_env = false
|
|
26
|
+
Rents.debugger = false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Get your App config if your not using TEST_ENV nor DEBUGGER
|
|
30
|
+
if (Rents.test_env.nil? && Rents.debugger.nil?) || (Rents.test_env == false && Rents.debugger == false)
|
|
31
|
+
if Rails.version[0].to_i >= 4
|
|
32
|
+
Rents.app_id = Rails.application.secrets.rents.app_id
|
|
33
|
+
Rents.secret_key = Rails.application.secrets.rents.app_secret_key
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/rents/connection.rb
CHANGED
|
@@ -11,18 +11,22 @@ module Rents
|
|
|
11
11
|
|
|
12
12
|
# Constructor
|
|
13
13
|
def initialize(params = {})
|
|
14
|
+
# An work around added to prevent a lot of changes
|
|
15
|
+
params = params.merge({test_env:true}) if Rents.test_env
|
|
16
|
+
params = params.merge({debugger:true}) if Rents.debugger
|
|
17
|
+
|
|
14
18
|
# Static part
|
|
15
19
|
self.request_params = {transaction:params}
|
|
16
20
|
setup_attrs(params)
|
|
17
21
|
setup_config
|
|
18
|
-
|
|
19
|
-
self.domain = '
|
|
22
|
+
self.domain = 'apprents.herokuapp.com' # 'rents.pagerenter.com.br'
|
|
23
|
+
self.domain = 'localhost:7000' if params[:debugger]
|
|
20
24
|
self.api_version = 'v1'
|
|
21
25
|
self.end_point = "http://#{self.domain}/api"
|
|
22
26
|
self.end_point_versioned = "http://#{self.domain}/api/#{self.api_version}"
|
|
23
27
|
|
|
24
28
|
# Dynamic env
|
|
25
|
-
setup_default_app
|
|
29
|
+
setup_default_app if params[:test_env]
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
# Full URL for the last request
|
|
@@ -66,6 +70,8 @@ module Rents
|
|
|
66
70
|
app = get_json_request[:app]
|
|
67
71
|
Rents.app_id = app[:id]
|
|
68
72
|
Rents.secret_key = app[:secret]
|
|
73
|
+
|
|
74
|
+
return puts 'Please run: rails g rents:install' if Rents.app_id.nil? || Rents.secret_key.nil?
|
|
69
75
|
self.auth = {app_id:Rents.app_id, secret_key:Rents.secret_key}
|
|
70
76
|
self.request_params.merge!(auth:self.auth)
|
|
71
77
|
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Rents
|
|
2
|
+
# Currency Obj, useful methods to work with many different countries
|
|
3
|
+
class Currency
|
|
4
|
+
# Receive it amount in Decimal and convert to operator str, like 10,00 or 10.00 to 1000
|
|
5
|
+
def self.to_operator_str amount
|
|
6
|
+
# Check invalid entry
|
|
7
|
+
return nil if amount.nil?
|
|
8
|
+
amount = amount.to_s if amount.is_a?Integer
|
|
9
|
+
|
|
10
|
+
# Convert from BigDecimal
|
|
11
|
+
if amount.is_a?BigDecimal
|
|
12
|
+
aux_amount_str = amount.to_s('F')
|
|
13
|
+
cents = aux_amount_str[aux_amount_str.index('.'), aux_amount_str.length]
|
|
14
|
+
|
|
15
|
+
# Check if there is a bug because the Decimal didn't recognize the second 0
|
|
16
|
+
aux_amount_str = "#{aux_amount_str}0"if cents.index('.')
|
|
17
|
+
|
|
18
|
+
return aux_amount_str.remove('.')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Create the amount as String
|
|
22
|
+
amount.is_a?(String) ? amount_str = amount : amount_str = amount.to_s
|
|
23
|
+
amount_str_not_formatted = amount_str.remove('.').remove(',')
|
|
24
|
+
|
|
25
|
+
# Create the full value
|
|
26
|
+
cents_value = amount_str_not_formatted[amount_str_not_formatted.length-2, amount_str_not_formatted.length-1]
|
|
27
|
+
integer_value = amount_str_not_formatted[0, amount_str_not_formatted.length-2]
|
|
28
|
+
|
|
29
|
+
# The return constraint
|
|
30
|
+
"#{integer_value}#{cents_value}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Receive it amount in Integer String (like 1000 that means 10,00 or 10.00) and convert to Decimal value
|
|
34
|
+
def self.to_decimal amount
|
|
35
|
+
# If it was passed a BigDecimal it must be passed to operator format
|
|
36
|
+
amount = Currency.to_operator_str(amount) if amount.is_a?BigDecimal
|
|
37
|
+
|
|
38
|
+
# Base vars
|
|
39
|
+
aux_amount = amount
|
|
40
|
+
cents_chars_counter = 2
|
|
41
|
+
|
|
42
|
+
# Building the currency str like BigDecimal understands
|
|
43
|
+
cents_str = aux_amount[aux_amount.length-cents_chars_counter..aux_amount.length]
|
|
44
|
+
integer_str = aux_amount[0, aux_amount.length-cents_chars_counter]
|
|
45
|
+
new_amount = "#{integer_str}.#{cents_str}"
|
|
46
|
+
|
|
47
|
+
BigDecimal.new new_amount
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Get it cents from operator amount formatted
|
|
51
|
+
def self.get_cents amount
|
|
52
|
+
aux = amount.to_s
|
|
53
|
+
cents_length = 2
|
|
54
|
+
aux[aux.length-cents_length, aux.length]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Receive a numeric form operator format & retrieve it
|
|
58
|
+
def self.have_cents? amount
|
|
59
|
+
aux = "#{amount.to_f/100}" if amount.is_a?(String) || amount.is_a?(Integer)
|
|
60
|
+
aux = amount.to_s if amount.is_a?Float
|
|
61
|
+
cents = aux[aux.index('.')+1, aux.length]
|
|
62
|
+
cents.length == 2 ? true : false
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
data/lib/rents/hash.rb
CHANGED
|
File without changes
|
data/lib/rents/status.rb
CHANGED
|
File without changes
|
data/lib/rents/string.rb
ADDED
data/lib/rents/transaction.rb
CHANGED
|
@@ -17,6 +17,11 @@ module Rents
|
|
|
17
17
|
self.resp[:rid]
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
# Return it Purchase URL, to pay on the OperatorPage
|
|
21
|
+
def purchase_url
|
|
22
|
+
self.resp[:purchase_url]
|
|
23
|
+
end
|
|
24
|
+
|
|
20
25
|
# GET /api/transactions/:rid by it attr
|
|
21
26
|
def verify
|
|
22
27
|
auth_hash = {}
|
|
@@ -29,7 +34,7 @@ module Rents
|
|
|
29
34
|
def charge_page full_resp=false
|
|
30
35
|
custom_http_params
|
|
31
36
|
# SetUp redirect dynamic if is test
|
|
32
|
-
self.request_params[:transaction][:redirect_link] = "#{self.redirect_link}
|
|
37
|
+
self.request_params[:transaction][:redirect_link] = "#{self.redirect_link}" if self.request_params[:transaction][:test_env]
|
|
33
38
|
|
|
34
39
|
# dynamic path (it is written when a specific method use it)
|
|
35
40
|
self.path = "transactions/page"
|
data/lib/rents/version.rb
CHANGED
data/lib/rents.rb
CHANGED
|
@@ -2,17 +2,24 @@
|
|
|
2
2
|
require 'json'
|
|
3
3
|
require 'curl'
|
|
4
4
|
require 'rest_client'
|
|
5
|
+
require 'bigdecimal'
|
|
6
|
+
require 'bigdecimal/util'
|
|
5
7
|
|
|
6
8
|
# Overrides
|
|
7
9
|
require 'rents/hash'
|
|
8
10
|
|
|
9
11
|
# Gem files
|
|
10
|
-
[:version, :connection, :status, :transaction].each { |lib| require "rents/#{lib}" }
|
|
12
|
+
[:version, :connection, :status, :transaction, :currency, :string].each { |lib| require "rents/#{lib}" }
|
|
11
13
|
|
|
12
14
|
module Rents
|
|
15
|
+
# Production settings
|
|
13
16
|
@@app_id = nil
|
|
14
17
|
@@secret_key = nil
|
|
15
18
|
|
|
19
|
+
# Tests settings
|
|
20
|
+
@@test_env = nil
|
|
21
|
+
@@debugger = nil
|
|
22
|
+
|
|
16
23
|
def self.app_id=(app_id)
|
|
17
24
|
@@app_id = app_id
|
|
18
25
|
end
|
|
@@ -28,4 +35,20 @@ module Rents
|
|
|
28
35
|
def self.secret_key
|
|
29
36
|
@@secret_key
|
|
30
37
|
end
|
|
38
|
+
|
|
39
|
+
def self.test_env
|
|
40
|
+
@@test_env
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.test_env=(test_env)
|
|
44
|
+
@@test_env = test_env
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.debugger
|
|
48
|
+
@@test_env
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.debugger=(debugger)
|
|
52
|
+
@@debugger = debugger
|
|
53
|
+
end
|
|
31
54
|
end
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
data/rents.gemspec
CHANGED
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
+
#================== GEMs to build it GEM, so its improve the development ==============================
|
|
22
|
+
# Base GEMs to build it gem
|
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
|
22
24
|
spec.add_development_dependency "rake", "~> 10.3", '>= 10.3.2'
|
|
23
25
|
|
|
@@ -27,10 +29,16 @@ Gem::Specification.new do |spec|
|
|
|
27
29
|
spec.add_development_dependency 'simplecov', '~> 0.7', '>= 0.7.1'
|
|
28
30
|
# Create readable attrs values
|
|
29
31
|
spec.add_development_dependency 'faker', '~> 1.4', '>= 1.4.2'
|
|
32
|
+
|
|
33
|
+
#================== GEMs to be used when it is called on a project ====================================
|
|
30
34
|
# For real user operator IP (4GeoLoc)
|
|
31
35
|
spec.add_dependency 'curb', "~> 0.8", '>= 0.8.6'
|
|
32
36
|
# HTTP REST Client
|
|
33
37
|
spec.add_dependency "rest-client", '~> 1.7', '>= 1.7.2'
|
|
34
38
|
# Easy JSON create
|
|
35
39
|
spec.add_dependency "multi_json", '~> 1.10', '>= 1.10.1'
|
|
40
|
+
# To pretty print on console
|
|
41
|
+
spec.add_dependency "colorize", '~> 0.7.3', '>= 0.7.3'
|
|
42
|
+
# To work with the Rails Numeric for currency
|
|
43
|
+
spec.add_dependency 'bigdecimal', '~> 1.2.5', '>= 1.2.5'
|
|
36
44
|
end
|
data/spec/helpers.rb
CHANGED
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe 'Numeric conversions' do
|
|
5
|
+
describe 'BigDecimalBackup conversions' do
|
|
6
|
+
# setup it vars to have the conversion tested, value: 1999 (nineteen ninety nine)
|
|
7
|
+
pt_br = '1.999,00'
|
|
8
|
+
en_us = '1,999.00'
|
|
9
|
+
|
|
10
|
+
# Value like the card operator uses
|
|
11
|
+
operator_expected_value = '199900'
|
|
12
|
+
operator_value = '199900'
|
|
13
|
+
decimal_expected_value = BigDecimal.new '1999.00'
|
|
14
|
+
|
|
15
|
+
# it is the Rails conversion form the Form for Decimal input
|
|
16
|
+
decimal_obj_pt_br = BigDecimal.new(pt_br)
|
|
17
|
+
decimal_obj_en_us = BigDecimal.new(en_us.remove('.').remove(','))
|
|
18
|
+
|
|
19
|
+
# Conversions
|
|
20
|
+
pt_br_converted = Currency.to_operator_str decimal_obj_pt_br
|
|
21
|
+
en_us_converted = Currency.to_operator_str decimal_obj_en_us
|
|
22
|
+
decimal_converted = Currency.to_decimal operator_value
|
|
23
|
+
|
|
24
|
+
context 'Operator Format value' do
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should be running correctly' do
|
|
29
|
+
status = Rents::Status.new
|
|
30
|
+
expect(status.http_code).to equal(200)
|
|
31
|
+
expect(status.api_code).to equal(200)
|
|
32
|
+
expect(status.message).not_to be nil
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
=end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Rents::Currency do
|
|
4
|
+
describe "Operator Format value" do
|
|
5
|
+
# setup it vars to have the conversion tested, value: 1999 (nineteen ninety nine)
|
|
6
|
+
pt_br = '1.999,00'
|
|
7
|
+
en_us = '1,999.00'
|
|
8
|
+
|
|
9
|
+
# Values expected
|
|
10
|
+
operator_value = '199900'
|
|
11
|
+
operator_expected_value = '199900'
|
|
12
|
+
integer_value = '199900'.to_i
|
|
13
|
+
decimal_value = BigDecimal.new '1999.00'
|
|
14
|
+
decimal_expected_value = BigDecimal.new '1999.00'
|
|
15
|
+
operator_with_cents = '300055' # R$ 3.000,55
|
|
16
|
+
non_cents_expected = '00'
|
|
17
|
+
cents_expected = '55'
|
|
18
|
+
|
|
19
|
+
# Values Converted to operator format
|
|
20
|
+
pt_br_operator_converted = Rents::Currency.to_operator_str pt_br
|
|
21
|
+
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
|
+
integer_converted = Rents::Currency.to_operator_str integer_value
|
|
25
|
+
cents_received = Rents::Currency.get_cents operator_with_cents
|
|
26
|
+
non_cents_received = Rents::Currency.get_cents operator_value
|
|
27
|
+
float_with_cents = 1000.55
|
|
28
|
+
float_without_cents = 1000.0
|
|
29
|
+
|
|
30
|
+
context 'Decimal to Operator' do
|
|
31
|
+
# Convert PT_BR
|
|
32
|
+
it 'PT_BR should be convertible' do
|
|
33
|
+
expect(pt_br_operator_converted).to be_a String
|
|
34
|
+
expect(pt_br_operator_converted.index('.')).to be_nil
|
|
35
|
+
expect(pt_br_operator_converted.index(',')).to be_nil
|
|
36
|
+
expect(pt_br_operator_converted).to be_integer
|
|
37
|
+
expect(pt_br_operator_converted).to be_equals operator_expected_value
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Convert EN_US
|
|
41
|
+
it 'EN_US should be convertible' do
|
|
42
|
+
expect(en_us_operator_converted).to be_a String
|
|
43
|
+
expect(en_us_operator_converted.index('.')).to be_nil
|
|
44
|
+
expect(en_us_operator_converted.index(',')).to be_nil
|
|
45
|
+
expect(en_us_operator_converted).to be_integer
|
|
46
|
+
expect(en_us_operator_converted).to be_equals operator_expected_value
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# To operator passing a BigDecimal instance
|
|
50
|
+
it 'should have a Operator format based on BigDecimal instance' do
|
|
51
|
+
expect(big_decimal_converted).to be_a String
|
|
52
|
+
expect(big_decimal_converted.index('.')).to be_nil
|
|
53
|
+
expect(big_decimal_converted.index(',')).to be_nil
|
|
54
|
+
expect(big_decimal_converted).to be_integer
|
|
55
|
+
expect(big_decimal_converted).to be_equals operator_expected_value
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context 'Integer to Operator' do
|
|
60
|
+
it 'should have a Operator format based on Integer instance' do
|
|
61
|
+
expect(integer_converted).to be_a String
|
|
62
|
+
expect(integer_converted.index('.')).to be_nil
|
|
63
|
+
expect(integer_converted.index(',')).to be_nil
|
|
64
|
+
expect(integer_converted).to be_integer
|
|
65
|
+
expect(integer_converted).to be_equals operator_expected_value
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
context 'Operator to Decimal' do
|
|
70
|
+
# Convert from the operator to BigDecimal instance, like rails does/need
|
|
71
|
+
it 'should be the BigDecimal expected' do
|
|
72
|
+
expect(decimal_converted).to be_a BigDecimal
|
|
73
|
+
expect(decimal_converted).to be == decimal_expected_value
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Convert operator with cents to float correctly
|
|
77
|
+
it 'should convert with cents correctly' do
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context 'Methods to work in operator format' do
|
|
83
|
+
it 'should retrieve existent cents' do
|
|
84
|
+
expect(cents_received).to be_equals cents_expected
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'should retrieve the non existent cents' do
|
|
88
|
+
expect(non_cents_received).to be_equals non_cents_expected
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'should have cents' do
|
|
92
|
+
expect(Rents::Currency.have_cents?(operator_with_cents)).to be_truthy
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'should not have cents' do
|
|
96
|
+
expect(Rents::Currency.have_cents?(operator_value)).to_not be_truthy
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it '(RECEIVING FLOAT) should have cents' do
|
|
100
|
+
expect(Rents::Currency.have_cents?(float_with_cents)).to be_truthy
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it '(RECEIVING FLOAT) should not have cents' do
|
|
104
|
+
expect(Rents::Currency.have_cents?(float_without_cents)).to_not be_truthy
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
data/spec/rents/status_spec.rb
CHANGED
|
File without changes
|
|
@@ -5,14 +5,12 @@ describe Rents::Transaction do
|
|
|
5
5
|
describe '(SUCCESS REQUEST) Operator - BuyPage' do
|
|
6
6
|
# ================ SetUp/Config ================
|
|
7
7
|
before(:all) do
|
|
8
|
+
Rents.test_env=true
|
|
9
|
+
Rents.debugger=true
|
|
8
10
|
base_url = 'http://localhost:7000'
|
|
9
11
|
|
|
10
|
-
@api_status = Rents::Status.new
|
|
11
|
-
test_env:true
|
|
12
|
-
})
|
|
13
|
-
|
|
12
|
+
@api_status = Rents::Status.new
|
|
14
13
|
@page_transaction = Rents::Transaction.new({
|
|
15
|
-
test_env:true,
|
|
16
14
|
card:{flag:'visa'},
|
|
17
15
|
amount: Random.rand(99999), # TODO: no error por rand menor que 99 (* mandatory) Amount in cents (1000 = R$ 10,00)
|
|
18
16
|
redirect_link: "#{base_url}/api/redirect_receiver" # (* optional) used only for CieloPage
|
|
@@ -27,21 +25,28 @@ describe Rents::Transaction do
|
|
|
27
25
|
|
|
28
26
|
# ================ Tests/Expects/Should ================
|
|
29
27
|
it 'resp should not be null' do
|
|
30
|
-
@page_resp.
|
|
28
|
+
expect(@page_resp).to_not be_nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should setup the rid accessible method' do
|
|
32
|
+
expect(@page_transaction.rid).to_not be_nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should setup the purchase_url accessible method' do
|
|
36
|
+
expect(@page_transaction.purchase_url).to_not be_nil
|
|
31
37
|
end
|
|
32
38
|
|
|
33
39
|
it 'resp should not have any error' do
|
|
34
40
|
error = @page_resp[:error]
|
|
35
41
|
error = @page_resp['error'] if error.nil?
|
|
36
|
-
error.
|
|
42
|
+
expect(error).to be_nil
|
|
37
43
|
end
|
|
38
44
|
|
|
39
45
|
it 'resp should be an accessible Operator URL' do
|
|
40
|
-
url = @
|
|
41
|
-
url = @page_resp[:purchase_url] if url.nil?
|
|
46
|
+
url = @page_transaction.purchase_url
|
|
42
47
|
|
|
43
|
-
url.
|
|
44
|
-
|
|
48
|
+
expect(url).to_not be_nil
|
|
49
|
+
expect(accessible?(url)).to be_truthy
|
|
45
50
|
end
|
|
46
51
|
|
|
47
52
|
it 'must be verifiable' do
|
|
@@ -51,12 +56,13 @@ describe Rents::Transaction do
|
|
|
51
56
|
error = verify_resp['error'] if error.nil?
|
|
52
57
|
|
|
53
58
|
# Validations
|
|
54
|
-
verify_resp.
|
|
55
|
-
error.
|
|
59
|
+
expect(verify_resp).to_not be_nil
|
|
60
|
+
expect(error).to be_nil
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
it 'must have a get accessible URL request' do
|
|
59
|
-
|
|
64
|
+
url = @page_transaction.url_requested+@page_transaction.request_params.it_keys_to_get_param
|
|
65
|
+
expect(be_accessible(url)).to be_truthy
|
|
60
66
|
end
|
|
61
67
|
end
|
|
62
68
|
|
|
@@ -64,6 +70,8 @@ describe Rents::Transaction do
|
|
|
64
70
|
describe '(BAD REQUEST) Operator - BuyPage' do
|
|
65
71
|
# SetUp/Config
|
|
66
72
|
before(:each) do
|
|
73
|
+
Rents.test_env = false
|
|
74
|
+
Rents.debugger = false
|
|
67
75
|
Rents.app_id = 1
|
|
68
76
|
Rents.secret_key = '12312321312$2a$10$NmV9EysKVLe8ItBdl9CHN.LF05bOuDdoOkmfptdbJs7cuaDWksuUu'
|
|
69
77
|
base_url = 'http://localhost:7000'
|
|
@@ -86,9 +94,9 @@ describe Rents::Transaction do
|
|
|
86
94
|
error = json_resp['error'] if error.nil?
|
|
87
95
|
|
|
88
96
|
# Check what expected
|
|
89
|
-
json_resp.
|
|
90
|
-
@page_resp.code.
|
|
91
|
-
error.
|
|
97
|
+
expect(json_resp).to be_a Hash
|
|
98
|
+
expect(@page_resp.code).to eq(200)
|
|
99
|
+
expect(error).to_not be_nil
|
|
92
100
|
end
|
|
93
101
|
end
|
|
94
102
|
end
|
data/spec/spec_helper.rb
CHANGED
|
File without changes
|
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: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ilton Garcia
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -164,6 +164,46 @@ dependencies:
|
|
|
164
164
|
- - ">="
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
166
|
version: 1.10.1
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: colorize
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - "~>"
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: 0.7.3
|
|
174
|
+
- - ">="
|
|
175
|
+
- !ruby/object:Gem::Version
|
|
176
|
+
version: 0.7.3
|
|
177
|
+
type: :runtime
|
|
178
|
+
prerelease: false
|
|
179
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
180
|
+
requirements:
|
|
181
|
+
- - "~>"
|
|
182
|
+
- !ruby/object:Gem::Version
|
|
183
|
+
version: 0.7.3
|
|
184
|
+
- - ">="
|
|
185
|
+
- !ruby/object:Gem::Version
|
|
186
|
+
version: 0.7.3
|
|
187
|
+
- !ruby/object:Gem::Dependency
|
|
188
|
+
name: bigdecimal
|
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
|
190
|
+
requirements:
|
|
191
|
+
- - "~>"
|
|
192
|
+
- !ruby/object:Gem::Version
|
|
193
|
+
version: 1.2.5
|
|
194
|
+
- - ">="
|
|
195
|
+
- !ruby/object:Gem::Version
|
|
196
|
+
version: 1.2.5
|
|
197
|
+
type: :runtime
|
|
198
|
+
prerelease: false
|
|
199
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
200
|
+
requirements:
|
|
201
|
+
- - "~>"
|
|
202
|
+
- !ruby/object:Gem::Version
|
|
203
|
+
version: 1.2.5
|
|
204
|
+
- - ">="
|
|
205
|
+
- !ruby/object:Gem::Version
|
|
206
|
+
version: 1.2.5
|
|
167
207
|
description: Ruby gem for Rent$ payment Gateway & Intermediary
|
|
168
208
|
email:
|
|
169
209
|
- ilton_unb@hotmail.com
|
|
@@ -176,19 +216,26 @@ files:
|
|
|
176
216
|
- LICENSE.txt
|
|
177
217
|
- README.md
|
|
178
218
|
- Rakefile
|
|
219
|
+
- lib/generators/rents/install_generator.rb
|
|
220
|
+
- lib/generators/templates/rents.rb
|
|
179
221
|
- lib/rents.rb
|
|
180
222
|
- lib/rents/connection.rb
|
|
223
|
+
- lib/rents/currency.rb
|
|
181
224
|
- lib/rents/hash.rb
|
|
182
225
|
- lib/rents/status.rb
|
|
226
|
+
- lib/rents/string.rb
|
|
183
227
|
- lib/rents/transaction.rb
|
|
184
228
|
- lib/rents/version.rb
|
|
185
229
|
- modelagem/Sequence - APIClient.asta
|
|
186
230
|
- modelagem/Structure - ClassDiagram.asta
|
|
231
|
+
- modelagem/WorkFlow - LocalGEM.asta
|
|
232
|
+
- modelagem/WorkFlow - LocalGEM.png
|
|
187
233
|
- modelagem/useful_files/card_operators/cielo/test_cards.txt
|
|
188
234
|
- modelagem/useful_files/card_operators/cielo/test_keys.txt
|
|
189
235
|
- rents.gemspec
|
|
190
236
|
- spec/helpers.rb
|
|
191
|
-
- spec/rents/
|
|
237
|
+
- spec/rents/conversions_spec.rb
|
|
238
|
+
- spec/rents/currency_spec.rb
|
|
192
239
|
- spec/rents/status_spec.rb
|
|
193
240
|
- spec/rents/transaction_spec.rb
|
|
194
241
|
- spec/spec_helper.rb
|
|
@@ -218,7 +265,8 @@ specification_version: 4
|
|
|
218
265
|
summary: Rent$ payment Gateway & Intermediary ruby gem
|
|
219
266
|
test_files:
|
|
220
267
|
- spec/helpers.rb
|
|
221
|
-
- spec/rents/
|
|
268
|
+
- spec/rents/conversions_spec.rb
|
|
269
|
+
- spec/rents/currency_spec.rb
|
|
222
270
|
- spec/rents/status_spec.rb
|
|
223
271
|
- spec/rents/transaction_spec.rb
|
|
224
272
|
- spec/spec_helper.rb
|
data/spec/rents/rents_spec.rb
DELETED