credit_card_validations 3.3.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +3 -0
- data/.travis.yml +21 -15
- data/Changelog.md +11 -0
- data/README.md +56 -53
- data/credit_card_validations.gemspec +11 -4
- data/lib/credit_card_validations/detector.rb +1 -0
- data/lib/credit_card_validations/version.rb +1 -1
- data/lib/data/brands.yaml +261 -34
- data/spec/active_model_spec.rb +9 -9
- data/spec/credit_card_validations_spec.rb +33 -33
- data/spec/factory_spec.rb +2 -2
- data/spec/fixtures/valid_cards.yml +94 -5
- data/spec/string_spec.rb +13 -13
- metadata +45 -16
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NjVkY2NhZjY2ZmJmMGQ5ZjVhNmNkM2JlZDAzYjM0YzhjYTVlZDdiMQ==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4e70cfc305b9764aadc325a22a15fc5827980b37b21d78edde8186a776485a59
|
4
|
+
data.tar.gz: 07dabf0813938def79e1959fbefba540a6129e05a025be2b4b92594fdf911579
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MmU2OTFiYTAyMzQ3NGQ0NDc3ZDEzMDk4YjM5YmEyMjc3ZGIyZWEwNGZmYThj
|
11
|
-
NjM0MGY3ZmFhNTc5Y2Y2NTM1ZTYwMDFhNDgyZjY1MWQ5NjYxNGM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MGZlNzM4YjRjZDVmYmY2NzI5ZTg1OGQ4ZTg4OGY3YzY1MTQ4MjA3NjVmMTJl
|
14
|
-
Mzg3NjcxM2ZiMWRhNmFkNWRmOTljMGFiOGU0ZDk3ZjQ1OWFiODk5ZDA2ZmNk
|
15
|
-
Y2E3Mzk3NmY0ZjVhZTkxYzcwYTMxNjNiYTQxY2RjYTJlOGRhYzA=
|
6
|
+
metadata.gz: 1187415e0ba2d57a30b6e47513b3a7b0de77254e5b27865df5f4d82e108495249c9f8e8e53e3512ca589f2268df0d68208ac8e0926f00d2acec20b674c8b544b
|
7
|
+
data.tar.gz: a94b5247435901e55cb67913e6872ae655dde008a38f77101b732b215b54aa2ad478d86f2fef7fa5306f65a3c7e66257572671408e3a674af57bd39c50f7d636
|
data/.gitignore
ADDED
data/.travis.yml
CHANGED
@@ -1,26 +1,32 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.3
|
8
|
-
-
|
3
|
+
- 2.1.10
|
4
|
+
- 2.2.10
|
5
|
+
- 2.3.5
|
6
|
+
- 2.4.5
|
7
|
+
- 2.5.3
|
8
|
+
- 2.6.3
|
9
|
+
- 3.0.0
|
10
|
+
- jruby-9.1.15.0
|
9
11
|
gemfile:
|
10
12
|
- gemfiles/rails1-4.gemfile
|
11
13
|
- gemfiles/rails5.gemfile
|
12
14
|
matrix:
|
13
15
|
exclude:
|
14
16
|
- gemfile: gemfiles/rails5.gemfile
|
15
|
-
rvm: 1.
|
16
|
-
- gemfile: gemfiles/rails5.gemfile
|
17
|
-
rvm: 2.0.0
|
18
|
-
- gemfile: gemfiles/rails5.gemfile
|
19
|
-
rvm: 2.1.9
|
17
|
+
rvm: 2.1.10
|
20
18
|
- gemfile: gemfiles/rails5.gemfile
|
21
19
|
rvm: jruby-9.1.6.0
|
20
|
+
- gemfile: gemfiles/rails1-4.gemfile
|
21
|
+
rvm: 2.5.3
|
22
|
+
- gemfile: gemfiles/rails1-4.gemfile
|
23
|
+
rvm: 2.6.3
|
24
|
+
- gemfile: gemfiles/rails1-4.gemfile
|
25
|
+
rvm: 3.0.0
|
26
|
+
allow_failures:
|
27
|
+
- rvm: 2.1.10
|
28
|
+
|
22
29
|
before_install:
|
23
|
-
- gem
|
24
|
-
-
|
25
|
-
-
|
26
|
-
- gem --version
|
30
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
31
|
+
- gem install bundler -v '< 2'
|
32
|
+
- export BUNDLE_PATH="${TRAVIS_BUILD_DIR}/vendor/bundle"
|
data/Changelog.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# 3.5.1
|
2
|
+
* Bump activemodel and activesupport versions
|
3
|
+
|
4
|
+
# 3.5.0
|
5
|
+
* Unionpay and Maestro range updates, PR #88
|
6
|
+
* Hipercard range updates , PR #79
|
7
|
+
* Visa and Discover length fix, PR #81
|
8
|
+
|
9
|
+
# 3.4.0
|
10
|
+
* Elo support enhanced, PR #75
|
11
|
+
|
1
12
|
# 3.3.0
|
2
13
|
* Added support for MIR card brand
|
3
14
|
|
data/README.md
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# CreditCardValidations
|
2
2
|
|
3
|
-
[![Build Status](http://img.shields.io/travis/
|
4
|
-
[![Dependency Status](http://img.shields.io/gemnasium/Fivell/credit_card_validations.svg)](https://gemnasium.com/Fivell/credit_card_validations)
|
3
|
+
[![Build Status](http://img.shields.io/travis/didww/credit_card_validations.svg)](https://travis-ci.org/didww/credit_card_validations)
|
5
4
|
[![Coverage Status](http://img.shields.io/coveralls/Fivell/credit_card_validations.svg)](https://coveralls.io/r/Fivell/credit_card_validations)
|
6
|
-
[![Code Climate](http://img.shields.io/codeclimate/github/Fivell/credit_card_validations.svg)](https://codeclimate.com/github/Fivell/credit_card_validations)
|
7
5
|
[![Gem Version](http://img.shields.io/gem/v/credit_card_validations.svg)](https://rubygems.org/gems/credit_card_validations)
|
8
|
-
[![License](http://img.shields.io/:license-mit-blue.svg)](http://
|
6
|
+
[![License](http://img.shields.io/:license-mit-blue.svg)](http://didww.mit-license.org)
|
9
7
|
|
10
8
|
|
11
9
|
Gem adds validator to check whether or not a given number actually falls within the ranges of possible numbers prior to performing such verification, and, as such, CreditCardValidations simply verifies that the credit card number provided is well-formed.
|
@@ -16,22 +14,28 @@ More info about card BIN numbers http://en.wikipedia.org/wiki/Bank_card_number
|
|
16
14
|
|
17
15
|
Add this line to your application's Gemfile:
|
18
16
|
|
19
|
-
|
17
|
+
```sh
|
18
|
+
$ gem 'credit_card_validations'
|
19
|
+
```
|
20
20
|
|
21
21
|
And then execute:
|
22
22
|
|
23
|
-
|
23
|
+
```sh
|
24
|
+
$ bundle
|
25
|
+
```
|
24
26
|
|
25
27
|
Or install it yourself as:
|
26
28
|
|
27
|
-
|
29
|
+
```sh
|
30
|
+
$ gem install credit_card_validations
|
31
|
+
```
|
28
32
|
|
29
33
|
## Usage
|
30
34
|
|
31
35
|
|
32
36
|
The following issuing institutes are accepted:
|
33
37
|
|
34
|
-
Name | Key |
|
38
|
+
| Name | Key |
|
35
39
|
--------------------- | ------------|
|
36
40
|
[American Express](http://en.wikipedia.org/wiki/American_Express) | :amex
|
37
41
|
[China UnionPay](http://en.wikipedia.org/wiki/China_UnionPay) | :unionpay
|
@@ -51,9 +55,9 @@ The following issuing institutes are accepted:
|
|
51
55
|
|
52
56
|
|
53
57
|
|
54
|
-
The following are supported with
|
58
|
+
The following are supported with plugins
|
55
59
|
|
56
|
-
Name | Key |
|
60
|
+
| Name | Key |
|
57
61
|
--------------------- | ------------|
|
58
62
|
[Diners Club US](http://en.wikipedia.org/wiki/Diners_Club_International#MasterCard_alliance) | :diners_us
|
59
63
|
[EnRoute](https://en.wikipedia.org/wiki/EnRoute_(credit_card)) | :en_route
|
@@ -64,12 +68,12 @@ The following are supported with with plugins
|
|
64
68
|
### Examples using string monkey patch
|
65
69
|
|
66
70
|
```ruby
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
require 'credit_card_validations/string'
|
72
|
+
'5274 5763 9425 9961'.credit_card_brand #=> :mastercard
|
73
|
+
'5274 5763 9425 9961'.credit_card_brand_name #=> "MasterCard"
|
74
|
+
'5274 5763 9425 9961'.valid_credit_card_brand?(:mastercard, :visa) #=> true
|
75
|
+
'5274 5763 9425 9961'.valid_credit_card_brand?(:amex) #=> false
|
76
|
+
'5274 5763 9425 9961'.valid_credit_card_brand?('MasterCard') #=> true
|
73
77
|
```
|
74
78
|
|
75
79
|
### ActiveModel support
|
@@ -77,73 +81,72 @@ The following are supported with with plugins
|
|
77
81
|
only for certain brands
|
78
82
|
|
79
83
|
```ruby
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
class CreditCardModel
|
85
|
+
attr_accessor :number
|
86
|
+
include ActiveModel::Validations
|
87
|
+
validates :number, credit_card_number: {brands: [:amex, :maestro]}
|
88
|
+
end
|
85
89
|
```
|
86
90
|
|
87
91
|
for all known brands
|
88
92
|
|
89
|
-
```ruby
|
90
|
-
|
93
|
+
```ruby
|
94
|
+
validates :number, presence: true, credit_card_number: true
|
91
95
|
```
|
92
96
|
|
93
97
|
### Examples using CreditCardValidations::Detector class
|
94
98
|
|
95
|
-
```ruby
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
99
|
+
```ruby
|
100
|
+
number = "4111111111111111"
|
101
|
+
detector = CreditCardValidations::Detector.new(number)
|
102
|
+
detector.brand #:visa
|
103
|
+
detector.visa? #true
|
104
|
+
detector.valid?(:mastercard,:maestro) #false
|
105
|
+
detector.valid?(:visa, :mastercard) #true
|
106
|
+
detector.issuer_category #"Banking and financial"
|
103
107
|
```
|
104
108
|
|
105
109
|
### Also You can add your own brand rules to detect other credit card brands/types
|
106
110
|
passing name,length(integer/array of integers) and prefix(string/array of strings)
|
107
111
|
Example
|
108
112
|
|
109
|
-
```ruby
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
113
|
+
```ruby
|
114
|
+
CreditCardValidations.add_brand(:voyager, {length: 15, prefixes: '86'})
|
115
|
+
voyager_test_card_number = '869926275400212'
|
116
|
+
CreditCardValidations::Detector.new(voyager_test_card_number).brand #:voyager
|
117
|
+
CreditCardValidations::Detector.new(voyager_test_card_number).voyager? #true
|
114
118
|
```
|
115
119
|
|
116
120
|
### Remove brands also supported
|
117
121
|
|
118
122
|
```ruby
|
119
|
-
|
123
|
+
CreditCardValidations::Detector.delete_brand(:maestro)
|
120
124
|
```
|
121
125
|
|
122
126
|
### Check luhn
|
123
127
|
|
124
|
-
```ruby
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
```
|
128
|
+
```ruby
|
129
|
+
CreditCardValidations::Detector.new(@credit_card_number).valid_luhn?
|
130
|
+
#or
|
131
|
+
CreditCardValidations::Luhn.valid?(@credit_card_number)
|
132
|
+
```
|
129
133
|
|
130
134
|
### Generate credit card numbers that pass validation
|
131
135
|
|
132
136
|
```ruby
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
+
CreditCardValidations::Factory.random(:amex)
|
138
|
+
# => "348051773827666"
|
139
|
+
CreditCardValidations::Factory.random(:maestro)
|
140
|
+
# => "6010430241237266856"
|
137
141
|
```
|
138
142
|
|
139
|
-
### Plugins
|
140
|
-
|
141
|
-
```ruby
|
142
|
-
require 'credit_card_validations/plugins/en_route'
|
143
|
-
require 'credit_card_validations/plugins/laser'
|
144
|
-
require 'credit_card_validations/plugins/diners_us'
|
143
|
+
### Plugins
|
145
144
|
|
146
|
-
|
145
|
+
```ruby
|
146
|
+
require 'credit_card_validations/plugins/en_route'
|
147
|
+
require 'credit_card_validations/plugins/laser'
|
148
|
+
require 'credit_card_validations/plugins/diners_us'
|
149
|
+
```
|
147
150
|
|
148
151
|
## Contributing
|
149
152
|
|
@@ -10,8 +10,14 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["fedoronchuk@gmail.com"]
|
11
11
|
gem.description = %q{A ruby gem for validating credit card numbers}
|
12
12
|
gem.summary = "gem should be used for credit card numbers validation, card brands detections, luhn checks"
|
13
|
-
gem.homepage = "http://
|
14
|
-
gem.license
|
13
|
+
gem.homepage = "http://didww.github.io/credit_card_validations/"
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.metadata = {
|
17
|
+
'bug_tracker_uri' => 'https://github.com/didww/credit_card_validations/issues',
|
18
|
+
'changelog_uri' => 'https://github.com/didww/credit_card_validations/blob/master/Changelog.md',
|
19
|
+
'source_code_uri' => 'https://github.com/didww/credit_card_validations'
|
20
|
+
}
|
15
21
|
|
16
22
|
gem.files = `git ls-files`.split($/)
|
17
23
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -19,10 +25,11 @@ Gem::Specification.new do |gem|
|
|
19
25
|
gem.require_paths = ["lib"]
|
20
26
|
|
21
27
|
|
22
|
-
gem.add_dependency "activemodel", ">= 3"
|
23
|
-
gem.add_dependency "activesupport", ">= 3"
|
28
|
+
gem.add_dependency "activemodel", ">= 3", "<= 6.2"
|
29
|
+
gem.add_dependency "activesupport", ">= 3", "<= 6.2"
|
24
30
|
|
25
31
|
|
32
|
+
gem.add_development_dependency "minitest", '~> 5.14.3'
|
26
33
|
gem.add_development_dependency "mocha", '1.1.0'
|
27
34
|
gem.add_development_dependency 'rake', '~> 10'
|
28
35
|
|
data/lib/data/brands.yaml
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
- :length:
|
5
5
|
- 13
|
6
6
|
- 16
|
7
|
+
- 19
|
7
8
|
:prefixes:
|
8
9
|
- '4'
|
9
10
|
:options:
|
@@ -66,21 +67,8 @@
|
|
66
67
|
- '38'
|
67
68
|
:options:
|
68
69
|
:brand_name: Diners Club
|
69
|
-
:discover:
|
70
|
-
:rules:
|
71
|
-
- :length:
|
72
|
-
- 16
|
73
|
-
:prefixes:
|
74
|
-
- '6011'
|
75
|
-
- '644'
|
76
|
-
- '645'
|
77
|
-
- '646'
|
78
|
-
- '647'
|
79
|
-
- '648'
|
80
|
-
- '649'
|
81
|
-
- '65'
|
82
70
|
:jcb:
|
83
|
-
:rules:
|
71
|
+
:rules:
|
84
72
|
- :length:
|
85
73
|
- 15
|
86
74
|
- 16
|
@@ -101,7 +89,7 @@
|
|
101
89
|
- :length:
|
102
90
|
- 19
|
103
91
|
:prefixes:
|
104
|
-
- '357266'
|
92
|
+
- '357266'
|
105
93
|
:options:
|
106
94
|
:brand_name: JCB
|
107
95
|
:solo:
|
@@ -174,11 +162,45 @@
|
|
174
162
|
- '604'
|
175
163
|
- '605'
|
176
164
|
- '6060'
|
177
|
-
- '
|
178
|
-
- '
|
179
|
-
- '
|
180
|
-
- '
|
181
|
-
- '
|
165
|
+
- '616788'
|
166
|
+
- '62183'
|
167
|
+
- '62186'
|
168
|
+
- '62188'
|
169
|
+
- '62198'
|
170
|
+
- '62199'
|
171
|
+
- '6220'
|
172
|
+
- '622110'
|
173
|
+
- '627089'
|
174
|
+
- '62709601'
|
175
|
+
- '6271'
|
176
|
+
- '6272'
|
177
|
+
- '6273'
|
178
|
+
- '6274'
|
179
|
+
- '6275'
|
180
|
+
- '6276'
|
181
|
+
- '6277'
|
182
|
+
- '6278'
|
183
|
+
- '6279'
|
184
|
+
- '6280'
|
185
|
+
- '6281'
|
186
|
+
- '6294'
|
187
|
+
- '6301'
|
188
|
+
- '630490'
|
189
|
+
- '633857'
|
190
|
+
- '63609'
|
191
|
+
- '6361'
|
192
|
+
- '636392'
|
193
|
+
- '636708'
|
194
|
+
- '637043'
|
195
|
+
- '637102'
|
196
|
+
- '637118'
|
197
|
+
- '637187'
|
198
|
+
- '637529'
|
199
|
+
- '639'
|
200
|
+
- '640'
|
201
|
+
- '641'
|
202
|
+
- '642'
|
203
|
+
- '643'
|
182
204
|
- '670'
|
183
205
|
- '671'
|
184
206
|
- '672'
|
@@ -205,11 +227,58 @@
|
|
205
227
|
- 18
|
206
228
|
- 19
|
207
229
|
:prefixes:
|
208
|
-
- '
|
230
|
+
- '620'
|
231
|
+
- '6210'
|
232
|
+
- '6212'
|
233
|
+
- '6213'
|
234
|
+
- '6214'
|
235
|
+
- '6215'
|
236
|
+
- '6216'
|
237
|
+
- '6217'
|
238
|
+
- '621977'
|
239
|
+
- '622126'
|
240
|
+
- '622127'
|
241
|
+
- '622128'
|
242
|
+
- '622129'
|
243
|
+
- '62213'
|
244
|
+
- '62214'
|
245
|
+
- '62215'
|
246
|
+
- '62216'
|
247
|
+
- '62217'
|
248
|
+
- '62218'
|
249
|
+
- '62220'
|
250
|
+
- '62221'
|
251
|
+
- '62222'
|
252
|
+
- '62223'
|
253
|
+
- '62224'
|
254
|
+
- '62225'
|
255
|
+
- '62226'
|
256
|
+
- '62227'
|
257
|
+
- '62228'
|
258
|
+
- '62229'
|
259
|
+
- '6223'
|
260
|
+
- '6224'
|
261
|
+
- '6225'
|
262
|
+
- '6226'
|
263
|
+
- '6227'
|
264
|
+
- '6228'
|
265
|
+
- '6229'
|
266
|
+
- '623'
|
209
267
|
- '624'
|
210
268
|
- '625'
|
211
269
|
- '626'
|
212
|
-
- '
|
270
|
+
- '62702'
|
271
|
+
- '62704'
|
272
|
+
- '62706'
|
273
|
+
- '62707'
|
274
|
+
- '6282'
|
275
|
+
- '6283'
|
276
|
+
- '6284'
|
277
|
+
- '6291'
|
278
|
+
- '6292'
|
279
|
+
- '632062'
|
280
|
+
- '685800'
|
281
|
+
- '69075'
|
213
282
|
:options:
|
214
283
|
:skip_luhn: true
|
215
284
|
:brand_name: China UnionPay
|
@@ -243,37 +312,155 @@
|
|
243
312
|
- 19
|
244
313
|
:prefixes:
|
245
314
|
- '384'
|
315
|
+
- '606282'
|
316
|
+
- '637095'
|
317
|
+
- '637568'
|
318
|
+
- '637599'
|
319
|
+
- '637609'
|
320
|
+
- '637612'
|
246
321
|
:elo:
|
247
322
|
:rules:
|
248
323
|
- :length:
|
249
324
|
- 16
|
250
325
|
:prefixes:
|
251
|
-
- '
|
326
|
+
- '401178'
|
327
|
+
- '401179'
|
328
|
+
- '431274'
|
252
329
|
- '438935'
|
253
330
|
- '451416'
|
254
|
-
- '
|
331
|
+
- '457393'
|
332
|
+
- '457631'
|
333
|
+
- '457632'
|
255
334
|
- '504175'
|
256
335
|
- '506699'
|
257
|
-
- '
|
258
|
-
- '
|
259
|
-
- '
|
260
|
-
- '
|
261
|
-
- '
|
262
|
-
- '
|
263
|
-
- '
|
264
|
-
- '
|
265
|
-
- '
|
336
|
+
- '50670'
|
337
|
+
- '50671'
|
338
|
+
- '506717'
|
339
|
+
- '506718'
|
340
|
+
- '50672'
|
341
|
+
- '506720'
|
342
|
+
- '506721'
|
343
|
+
- '506724'
|
344
|
+
- '506725'
|
345
|
+
- '506726'
|
346
|
+
- '506727'
|
347
|
+
- '506728'
|
348
|
+
- '506729'
|
349
|
+
- '50673'
|
350
|
+
- '50674'
|
351
|
+
- '50675'
|
352
|
+
- '50676'
|
353
|
+
- '506770'
|
354
|
+
- '506771'
|
355
|
+
- '506772'
|
356
|
+
- '506773'
|
357
|
+
- '506774'
|
358
|
+
- '506775'
|
359
|
+
- '506776'
|
360
|
+
- '506777'
|
361
|
+
- '506778'
|
362
|
+
- '50900'
|
363
|
+
- '509013'
|
364
|
+
- '50902'
|
365
|
+
- '509031'
|
366
|
+
- '509033'
|
367
|
+
- '509035'
|
368
|
+
- '509036'
|
369
|
+
- '509037'
|
370
|
+
- '509038'
|
371
|
+
- '509039'
|
372
|
+
- '50904'
|
266
373
|
- '509050'
|
267
374
|
- '509051'
|
268
375
|
- '509052'
|
376
|
+
- '509053'
|
269
377
|
- '509064'
|
270
378
|
- '509066'
|
271
379
|
- '509067'
|
272
380
|
- '509068'
|
273
381
|
- '509069'
|
382
|
+
- '509072'
|
274
383
|
- '509074'
|
384
|
+
- '509076'
|
385
|
+
- '509077'
|
386
|
+
- '509078'
|
387
|
+
- '509079'
|
388
|
+
- '509080'
|
389
|
+
- '509081'
|
390
|
+
- '509082'
|
391
|
+
- '509083'
|
392
|
+
- '509085'
|
275
393
|
- '636297'
|
276
|
-
- '
|
394
|
+
- '636368'
|
395
|
+
- '650031'
|
396
|
+
- '650032'
|
397
|
+
- '650033'
|
398
|
+
- '650035'
|
399
|
+
- '650036'
|
400
|
+
- '650037'
|
401
|
+
- '650038'
|
402
|
+
- '650039'
|
403
|
+
- '65004'
|
404
|
+
- '650050'
|
405
|
+
- '650051'
|
406
|
+
- '650405'
|
407
|
+
- '650406'
|
408
|
+
- '650407'
|
409
|
+
- '650408'
|
410
|
+
- '650409'
|
411
|
+
- '65041'
|
412
|
+
- '65042'
|
413
|
+
- '65043'
|
414
|
+
- '650485'
|
415
|
+
- '650486'
|
416
|
+
- '650487'
|
417
|
+
- '650488'
|
418
|
+
- '650489'
|
419
|
+
- '65049'
|
420
|
+
- '65050'
|
421
|
+
- '65051'
|
422
|
+
- '65052'
|
423
|
+
- '650530'
|
424
|
+
- '650531'
|
425
|
+
- '650532'
|
426
|
+
- '650533'
|
427
|
+
- '650534'
|
428
|
+
- '650535'
|
429
|
+
- '650536'
|
430
|
+
- '650537'
|
431
|
+
- '650538'
|
432
|
+
- '650541'
|
433
|
+
- '650700'
|
434
|
+
- '650720'
|
435
|
+
- '650901'
|
436
|
+
- '650921'
|
437
|
+
- '650922'
|
438
|
+
- '650923'
|
439
|
+
- '650924'
|
440
|
+
- '650925'
|
441
|
+
- '650926'
|
442
|
+
- '650927'
|
443
|
+
- '650928'
|
444
|
+
- '650929'
|
445
|
+
- '65093'
|
446
|
+
- '65094'
|
447
|
+
- '65095'
|
448
|
+
- '65096'
|
449
|
+
- '650970'
|
450
|
+
- '650971'
|
451
|
+
- '650972'
|
452
|
+
- '650973'
|
453
|
+
- '650974'
|
454
|
+
- '650975'
|
455
|
+
- '650976'
|
456
|
+
- '650977'
|
457
|
+
- '650978'
|
458
|
+
- '651652'
|
459
|
+
- '65500'
|
460
|
+
- '65501'
|
461
|
+
- '655021'
|
462
|
+
- '65503'
|
463
|
+
- '65504'
|
277
464
|
:options:
|
278
465
|
:skip_luhn: true
|
279
466
|
:brand_name: Elo
|
@@ -287,3 +474,43 @@
|
|
287
474
|
- '2202'
|
288
475
|
- '2203'
|
289
476
|
- '2204'
|
477
|
+
:discover:
|
478
|
+
:rules:
|
479
|
+
- :length:
|
480
|
+
- 16
|
481
|
+
- 19
|
482
|
+
:prefixes:
|
483
|
+
- '300'
|
484
|
+
- '301'
|
485
|
+
- '302'
|
486
|
+
- '303'
|
487
|
+
- '304'
|
488
|
+
- '305'
|
489
|
+
- '38'
|
490
|
+
- '39'
|
491
|
+
- '60110'
|
492
|
+
- '60112'
|
493
|
+
- '60113'
|
494
|
+
- '601140'
|
495
|
+
- '601141'
|
496
|
+
- '601142'
|
497
|
+
- '601143'
|
498
|
+
- '601144'
|
499
|
+
- '601174'
|
500
|
+
- '601177'
|
501
|
+
- '601178'
|
502
|
+
- '601179'
|
503
|
+
- '601186'
|
504
|
+
- '601187'
|
505
|
+
- '601188'
|
506
|
+
- '601189'
|
507
|
+
- '60119'
|
508
|
+
- '644'
|
509
|
+
- '645'
|
510
|
+
- '646'
|
511
|
+
- '647'
|
512
|
+
- '648'
|
513
|
+
- '649'
|
514
|
+
- '65'
|
515
|
+
:options:
|
516
|
+
:brand_name: Discover
|
data/spec/active_model_spec.rb
CHANGED
@@ -9,9 +9,9 @@ describe 'ActiveModel Validator' do
|
|
9
9
|
card = model.dup
|
10
10
|
card.card_type = 'Master Card'
|
11
11
|
card.number6 = CreditCardValidations::Factory.random(:visa)
|
12
|
-
card.valid
|
12
|
+
expect(card.valid?).must_equal false
|
13
13
|
card.number6 = CreditCardValidations::Factory.random(:mastercard)
|
14
|
-
card.valid
|
14
|
+
expect(card.valid?).must_equal true
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -22,7 +22,7 @@ describe 'ActiveModel Validator' do
|
|
22
22
|
card = model
|
23
23
|
card.number4 = number
|
24
24
|
card.number5 = number
|
25
|
-
card.valid
|
25
|
+
expect(card.valid?).must_equal true
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -33,8 +33,8 @@ describe 'ActiveModel Validator' do
|
|
33
33
|
VALID_NUMBERS.except(:amex, :maestro).each do |_, numbers|
|
34
34
|
card = model
|
35
35
|
card.number = numbers.first
|
36
|
-
card.valid
|
37
|
-
card.errors[:number].include?(card.errors.generate_message(:number, :invalid)).must_equal true
|
36
|
+
expect(card.valid?).must_equal false
|
37
|
+
expect(card.errors[:number].include?(card.errors.generate_message(:number, :invalid))).must_equal true
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -42,7 +42,7 @@ describe 'ActiveModel Validator' do
|
|
42
42
|
VALID_NUMBERS.except(:amex, :maestro).each do |_, numbers|
|
43
43
|
card = model
|
44
44
|
card.number3 = numbers.first
|
45
|
-
card.valid
|
45
|
+
expect(card.valid?).must_equal true
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -53,7 +53,7 @@ describe 'ActiveModel Validator' do
|
|
53
53
|
card = model
|
54
54
|
card.number = numbers.first
|
55
55
|
card.number2 = numbers.first
|
56
|
-
card.valid
|
56
|
+
expect(card.valid?).must_equal true
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -62,8 +62,8 @@ describe 'ActiveModel Validator' do
|
|
62
62
|
it 'should allow custom message' do
|
63
63
|
card = model
|
64
64
|
card.number7 = 'wrong'
|
65
|
-
card.valid
|
66
|
-
card.errors[:number7].must_equal ['Custom message']
|
65
|
+
expect(card.valid?).must_equal false
|
66
|
+
expect(card.errors[:number7]).must_equal ['Custom message']
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -10,7 +10,7 @@ describe CreditCardValidations do
|
|
10
10
|
describe 'MMI' do
|
11
11
|
it 'should detect issuer category' do
|
12
12
|
d = detector(VALID_NUMBERS[:visa].first)
|
13
|
-
d.issuer_category.must_equal CreditCardValidations::Mmi::ISSUER_CATEGORIES[d.number[0]]
|
13
|
+
expect(d.issuer_category).must_equal CreditCardValidations::Mmi::ISSUER_CATEGORIES[d.number[0]]
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -20,17 +20,17 @@ describe CreditCardValidations do
|
|
20
20
|
}
|
21
21
|
it 'should call Luhn.valid? once' do
|
22
22
|
CreditCardValidations::Luhn.expects(:valid?).with(card_detector.number).once
|
23
|
-
card_detector.valid?(:visa, :unionpay).must_equal true
|
23
|
+
expect(card_detector.valid?(:visa, :unionpay)).must_equal true
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should call Luhn.valid? twice' do
|
27
27
|
CreditCardValidations::Luhn.expects(:valid?).with(card_detector.number).twice
|
28
|
-
card_detector.valid?(:visa, :mastercard).must_equal false
|
28
|
+
expect(card_detector.valid?(:visa, :mastercard)).must_equal false
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should not call Luhn.valid?' do
|
32
32
|
CreditCardValidations::Luhn.expects(:valid?).never
|
33
|
-
card_detector.valid?(:unionpay).must_equal true
|
33
|
+
expect(card_detector.valid?(:unionpay)).must_equal true
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
@@ -40,7 +40,7 @@ describe CreditCardValidations do
|
|
40
40
|
VALID_NUMBERS.each do |brand, card_numbers|
|
41
41
|
if has_luhn_check_rule?(brand)
|
42
42
|
card_numbers.each do |number|
|
43
|
-
luhn_valid?(detector(number).number).must_equal true
|
43
|
+
expect(luhn_valid?(detector(number).number)).must_equal true
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -49,56 +49,56 @@ describe CreditCardValidations do
|
|
49
49
|
it 'should check valid brand' do
|
50
50
|
VALID_NUMBERS.each do |brand, card_numbers|
|
51
51
|
card_numbers.each do |card_number|
|
52
|
-
detector(card_number).send("#{brand}?").must_equal true
|
53
|
-
detector(card_number).brand.must_equal brand
|
52
|
+
expect(detector(card_number).send("#{brand}?")).must_equal true
|
53
|
+
expect(detector(card_number).brand).must_equal brand
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should check if card invalid' do
|
59
59
|
INVALID_NUMBERS.each do |card_number|
|
60
|
-
detector(card_number).valid
|
61
|
-
detector(card_number).brand.must_be_nil
|
60
|
+
expect(detector(card_number).valid?).must_equal false
|
61
|
+
expect(detector(card_number).brand).must_be_nil
|
62
62
|
VALID_NUMBERS.keys.each do |brand|
|
63
|
-
detector(card_number).send("#{brand}?").must_equal false
|
63
|
+
expect(detector(card_number).send("#{brand}?")).must_equal false
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should detect by full brand name' do
|
69
69
|
amex = CreditCardValidations::Factory.random(:amex)
|
70
|
-
detector(amex).valid?('American Express').must_equal true
|
70
|
+
expect(detector(amex).valid?('American Express')).must_equal true
|
71
71
|
visa = CreditCardValidations::Factory.random(:visa)
|
72
|
-
detector(visa).valid?('American Express').must_equal false
|
72
|
+
expect(detector(visa).valid?('American Express')).must_equal false
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should support multiple brands for single check' do
|
76
76
|
VALID_NUMBERS.slice(:visa, :mastercard).each do |key, value|
|
77
|
-
detector(value.first).brand(:visa, :mastercard).must_equal key
|
77
|
+
expect(detector(value.first).brand(:visa, :mastercard)).must_equal key
|
78
78
|
end
|
79
79
|
|
80
80
|
VALID_NUMBERS.except(:visa, :mastercard).each do |_, value|
|
81
|
-
detector(value.first).brand(:visa, :mastercard).must_be_nil
|
81
|
+
expect(detector(value.first).brand(:visa, :mastercard)).must_be_nil
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'should check if valid brand without arguments' do
|
86
86
|
VALID_NUMBERS.each do |key, value|
|
87
87
|
value.each do |card_number|
|
88
|
-
detector(card_number).valid?(key).must_equal true
|
89
|
-
assert detector(card_number).valid
|
88
|
+
expect(detector(card_number).valid?(key)).must_equal true
|
89
|
+
expect(assert detector(card_number).valid?).must_equal true
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'should not be valid? if wrong brand' do
|
95
|
-
detector(VALID_NUMBERS[:visa].first).valid?(:mastercard).must_equal false
|
96
|
-
detector(VALID_NUMBERS[:mastercard].first).valid?(:visa).must_equal false
|
95
|
+
expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard)).must_equal false
|
96
|
+
expect(detector(VALID_NUMBERS[:mastercard].first).valid?(:visa)).must_equal false
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'should be valid? if right brand' do
|
100
|
-
detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :visa).must_equal true
|
101
|
-
detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :amex).must_equal false
|
100
|
+
expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :visa)).must_equal true
|
101
|
+
expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :amex)).must_equal false
|
102
102
|
end
|
103
103
|
|
104
104
|
|
@@ -110,9 +110,9 @@ describe CreditCardValidations do
|
|
110
110
|
|
111
111
|
it 'should validate number as voyager' do
|
112
112
|
CreditCardValidations::Detector.add_brand(:voyager, length: 15, prefixes: '86')
|
113
|
-
detector(voyager_number).valid?(:voyager).must_equal true
|
114
|
-
detector(voyager_number).voyager
|
115
|
-
detector(voyager_number).brand.must_equal :voyager
|
113
|
+
expect(detector(voyager_number).valid?(:voyager)).must_equal true
|
114
|
+
expect(detector(voyager_number).voyager?).must_equal true
|
115
|
+
expect(detector(voyager_number).brand).must_equal :voyager
|
116
116
|
end
|
117
117
|
|
118
118
|
describe 'Add voyager rule' do
|
@@ -121,9 +121,9 @@ describe CreditCardValidations do
|
|
121
121
|
end
|
122
122
|
|
123
123
|
it 'should validate number as voyager' do
|
124
|
-
detector(voyager_number).valid?(:voyager).must_equal true
|
125
|
-
detector(voyager_number).voyager
|
126
|
-
detector(voyager_number).brand.must_equal :voyager
|
124
|
+
expect(detector(voyager_number).valid?(:voyager)).must_equal true
|
125
|
+
expect(detector(voyager_number).voyager?).must_equal true
|
126
|
+
expect(detector(voyager_number).brand).must_equal :voyager
|
127
127
|
end
|
128
128
|
|
129
129
|
describe 'Remove voyager rule' do
|
@@ -132,8 +132,8 @@ describe CreditCardValidations do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'should not validate number as voyager' do
|
135
|
-
detector(voyager_number).respond_to?(:voyager?).must_equal false
|
136
|
-
detector(voyager_number).brand.must_be_nil
|
135
|
+
expect(detector(voyager_number).respond_to?(:voyager?)).must_equal false
|
136
|
+
expect(detector(voyager_number).brand).must_be_nil
|
137
137
|
end
|
138
138
|
end
|
139
139
|
end
|
@@ -142,20 +142,20 @@ describe CreditCardValidations do
|
|
142
142
|
describe 'plugins' do
|
143
143
|
[:diners_us, :en_route, :laser].each do |brand|
|
144
144
|
it "should support #{brand}" do
|
145
|
-
-> { CreditCardValidations::Factory.random(brand) }.
|
145
|
+
expect(-> { CreditCardValidations::Factory.random(brand) }).
|
146
146
|
must_raise(CreditCardValidations::Error)
|
147
147
|
custom_number = 'some_number'
|
148
|
-
detector(custom_number).respond_to?("#{brand}?").must_equal false
|
148
|
+
expect(detector(custom_number).respond_to?("#{brand}?")).must_equal false
|
149
149
|
require "credit_card_validations/plugins/#{brand}"
|
150
150
|
number = CreditCardValidations::Factory.random(brand)
|
151
|
-
detector(number).valid?("#{brand}".to_sym).must_equal true
|
152
|
-
detector(custom_number).respond_to?("#{brand}?").must_equal true
|
151
|
+
expect(detector(number).valid?("#{brand}".to_sym)).must_equal true
|
152
|
+
expect(detector(custom_number).respond_to?("#{brand}?")).must_equal true
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'should raise Error if no brand added before' do
|
158
|
-
-> { CreditCardValidations::Detector::add_rule(:undefined_brand, 20, [20]) }.
|
158
|
+
expect(-> { CreditCardValidations::Detector::add_rule(:undefined_brand, 20, [20]) }).
|
159
159
|
must_raise(CreditCardValidations::Error)
|
160
160
|
end
|
161
161
|
end
|
data/spec/factory_spec.rb
CHANGED
@@ -4,14 +4,14 @@ describe CreditCardValidations::Factory do
|
|
4
4
|
|
5
5
|
it 'should generate random brand' do
|
6
6
|
number = CreditCardValidations::Factory.random
|
7
|
-
CreditCardValidations::Detector.new(number).valid
|
7
|
+
expect(CreditCardValidations::Detector.new(number).valid?).must_equal true
|
8
8
|
end
|
9
9
|
|
10
10
|
CreditCardValidations::Detector.brands.keys.sort.each do |key|
|
11
11
|
describe "#{key}" do
|
12
12
|
it "should generate valid #{key}" do
|
13
13
|
number = CreditCardValidations::Factory.random(key)
|
14
|
-
CreditCardValidations::Detector.new(number).valid?(key).must_equal true
|
14
|
+
expect(CreditCardValidations::Detector.new(number).valid?(key)).must_equal true
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -56,9 +56,44 @@
|
|
56
56
|
- 5641 8200 0000 0005
|
57
57
|
- 5033 9619 8909 17
|
58
58
|
- 5868 2416 0825 5333 38
|
59
|
+
- 6167 8856 4660 5238
|
60
|
+
- 6218 3782 7162 0705
|
61
|
+
- 6218 6064 1843 1366
|
62
|
+
- 6218 8455 3580 6171
|
63
|
+
- 6219 8470 1538 3118
|
64
|
+
- 6219 9203 6534 5837
|
65
|
+
- 6220 1885 7707 6726
|
66
|
+
- 6221 1083 1803 2381
|
67
|
+
- 6270 8984 1174 5752
|
68
|
+
- 6270 9601 6484 7142
|
69
|
+
- 6271 0126 3275 2014
|
70
|
+
- 6272 5470 0241 5113
|
71
|
+
- 6273 5523 8170 6073
|
72
|
+
- 6274 4145 1171 2555
|
73
|
+
- 6275 3486 8618 0058
|
74
|
+
- 6276 0982 4454 3458
|
75
|
+
- 6277 6702 4773 1576
|
76
|
+
- 6278 1636 1660 6511
|
77
|
+
- 6279 7366 4387 5768
|
78
|
+
- 6280 4737 1307 4604
|
79
|
+
- 6281 5524 1682 8637
|
80
|
+
- 6294 4318 2601 2816
|
81
|
+
- 6301 1412 8720 7778
|
82
|
+
- 6304 9003 0332 3654
|
83
|
+
- 6304 9086 6523 0248 21
|
84
|
+
- 6338 5705 2835 6175
|
85
|
+
- 6360 9440 0747 0123
|
86
|
+
- 6361 4178 1150 8502
|
87
|
+
- 6363 9214 5556 2632
|
88
|
+
- 6367 0803 6033 4748
|
89
|
+
- 6370 4379 0022 2632
|
90
|
+
- 6371 0283 5125 2860
|
91
|
+
- 6371 1802 0780 5415
|
92
|
+
- 6371 8718 1864 7655
|
93
|
+
- 6375 2978 8623 4844
|
94
|
+
- 6400 0578 8840 6561
|
59
95
|
- 6799 9901 0000 0000 019
|
60
96
|
- 6390 0200 0000 000003
|
61
|
-
- 6304 9506 0000 0000 00
|
62
97
|
- 6304 9000 1774 0292 441
|
63
98
|
:jcb:
|
64
99
|
- 3575 7591 5225 4876
|
@@ -74,9 +109,61 @@
|
|
74
109
|
- 6334 7306 0000 0000 00
|
75
110
|
- 6767 6767 6767 6767 671
|
76
111
|
:unionpay:
|
112
|
+
- 6205 4687 6758 6422
|
113
|
+
- 6210 0345 5222 3424
|
114
|
+
- 6212 2545 6614 8478
|
115
|
+
- 6213 0005 0723 4136
|
116
|
+
- 6214 0114 0514 5414
|
117
|
+
- 6215 4794 3842 9213
|
118
|
+
- 6216 2080 3647 3680
|
119
|
+
- 6217 3228 8155 9136
|
120
|
+
- 6219 7704 6772 7014
|
121
|
+
- 6221 2610 6056 0875
|
122
|
+
- 6221 2703 3387 7511
|
123
|
+
- 6221 2860 4501 8723
|
124
|
+
- 6221 2940 0187 5508
|
125
|
+
- 6221 3008 0432 3735
|
126
|
+
- 6221 4035 2650 5041
|
127
|
+
- 6221 5050 3211 0387
|
128
|
+
- 6221 6206 2057 6335
|
129
|
+
- 6221 7084 6822 1773
|
130
|
+
- 6221 8075 5266 5356
|
131
|
+
- 6222 0036 3722 7888
|
132
|
+
- 6222 1058 8000 7162
|
133
|
+
- 6222 2061 3672 5803
|
134
|
+
- 6222 3068 2276 5616
|
135
|
+
- 6222 4053 4600 2835
|
136
|
+
- 6222 5203 3381 7225
|
137
|
+
- 6222 6080 1686 1014
|
138
|
+
- 6222 7088 5121 8153
|
139
|
+
- 6222 8035 1083 2211
|
140
|
+
- 6222 9175 6828 0444
|
141
|
+
- 6223 7906 8294 4834
|
142
|
+
- 6224 0617 0122 1813
|
143
|
+
- 6225 2033 2312 4467
|
144
|
+
- 6226 0315 6271 3412
|
145
|
+
- 6227 5171 6866 2101
|
146
|
+
- 6228 3658 3631 6034
|
147
|
+
- 6229 9701 3846 6087
|
148
|
+
- 6230 0388 8477 1162
|
149
|
+
- 6234 6051 1836 1717
|
150
|
+
- 6244 1608 1703 3165
|
151
|
+
- 6251 7173 7983 2118
|
152
|
+
- 6262 1704 1722 3287
|
77
153
|
- 6264 1852 1292 2132 067
|
78
|
-
- 6288 9977 1545 2584
|
79
154
|
- 6269 9920 5813 4322
|
155
|
+
- 6270 2754 6260 5740
|
156
|
+
- 6270 4000 5254 5060
|
157
|
+
- 6270 6014 6481 7266
|
158
|
+
- 6270 7647 4746 0500
|
159
|
+
- 6282 7754 7900 5608
|
160
|
+
- 6283 5632 6428 3062
|
161
|
+
- 6284 6110 6682 6452
|
162
|
+
- 6291 8025 7481 1158
|
163
|
+
- 6292 6014 3461 6826
|
164
|
+
- 6320 6205 2613 4288
|
165
|
+
- 6858 0012 5116 6441
|
166
|
+
- 6907 5577 4227 8443
|
80
167
|
:dankort:
|
81
168
|
- 5019 7170 1010 3742
|
82
169
|
:switch:
|
@@ -87,10 +174,10 @@
|
|
87
174
|
:hipercard:
|
88
175
|
- 3841 0058 9908 8180 330
|
89
176
|
:elo:
|
90
|
-
- '4011
|
177
|
+
- '4011 7841 3850 9070'
|
91
178
|
- '4389 3555 4728 7502'
|
92
|
-
- '
|
93
|
-
- '4576
|
179
|
+
- '4573 9320 5642 0699'
|
180
|
+
- '4576 3198 7564 9522'
|
94
181
|
- '5041 7572 2687 1008'
|
95
182
|
- '5066 9917 1703 9876'
|
96
183
|
- '5067 5391 6526 0388'
|
@@ -113,5 +200,7 @@
|
|
113
200
|
- '5090 7463 8779 6948'
|
114
201
|
- '6362 9745 2190 7765'
|
115
202
|
- '6363 6850 2897 2643'
|
203
|
+
- '6504 9799 9991 0279'
|
204
|
+
- '6516 5299 9991 0328'
|
116
205
|
:mir:
|
117
206
|
- 2202 1234 1234 1234
|
data/spec/string_spec.rb
CHANGED
@@ -8,25 +8,25 @@ describe 'String ext' do
|
|
8
8
|
let(:invalid) { INVALID_NUMBERS.sample }
|
9
9
|
|
10
10
|
it 'should allow detect brand for mastercard' do
|
11
|
-
mastercard.credit_card_brand.must_equal :mastercard
|
12
|
-
mastercard.credit_card_brand_name.must_equal 'MasterCard'
|
13
|
-
mastercard.valid_credit_card_brand?(:mastercard).must_equal true
|
14
|
-
mastercard.valid_credit_card_brand?('MasterCard').must_equal true
|
15
|
-
mastercard.valid_credit_card_brand?(:visa, :amex).must_equal false
|
11
|
+
expect(mastercard.credit_card_brand).must_equal :mastercard
|
12
|
+
expect(mastercard.credit_card_brand_name).must_equal 'MasterCard'
|
13
|
+
expect(mastercard.valid_credit_card_brand?(:mastercard)).must_equal true
|
14
|
+
expect(mastercard.valid_credit_card_brand?('MasterCard')).must_equal true
|
15
|
+
expect(mastercard.valid_credit_card_brand?(:visa, :amex)).must_equal false
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should allow detect brand for visa' do
|
19
|
-
visa.credit_card_brand.must_equal :visa
|
20
|
-
visa.credit_card_brand_name.must_equal 'Visa'
|
21
|
-
visa.valid_credit_card_brand?(:mastercard).must_equal false
|
22
|
-
visa.valid_credit_card_brand?(:visa, :amex).must_equal true
|
19
|
+
expect(visa.credit_card_brand).must_equal :visa
|
20
|
+
expect(visa.credit_card_brand_name).must_equal 'Visa'
|
21
|
+
expect(visa.valid_credit_card_brand?(:mastercard)).must_equal false
|
22
|
+
expect(visa.valid_credit_card_brand?(:visa, :amex)).must_equal true
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should not allow detect brand for invalid card' do
|
26
|
-
invalid.credit_card_brand.must_be_nil
|
27
|
-
invalid.credit_card_brand_name.must_be_nil
|
28
|
-
invalid.valid_credit_card_brand?(:mastercard).must_equal false
|
29
|
-
invalid.valid_credit_card_brand?(:visa, :amex).must_equal false
|
26
|
+
expect(invalid.credit_card_brand).must_be_nil
|
27
|
+
expect(invalid.credit_card_brand_name).must_be_nil
|
28
|
+
expect(invalid.valid_credit_card_brand?(:mastercard)).must_equal false
|
29
|
+
expect(invalid.valid_credit_card_brand?(:visa, :amex)).must_equal false
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
metadata
CHANGED
@@ -1,43 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credit_card_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3'
|
20
|
+
- - "<="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6.2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3'
|
30
|
+
- - "<="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6.2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: activesupport
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- -
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '3'
|
40
|
+
- - "<="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '6.2'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
|
-
- -
|
47
|
+
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '3'
|
50
|
+
- - "<="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '6.2'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: minitest
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 5.14.3
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 5.14.3
|
41
67
|
- !ruby/object:Gem::Dependency
|
42
68
|
name: mocha
|
43
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,14 +82,14 @@ dependencies:
|
|
56
82
|
name: rake
|
57
83
|
requirement: !ruby/object:Gem::Requirement
|
58
84
|
requirements:
|
59
|
-
- - ~>
|
85
|
+
- - "~>"
|
60
86
|
- !ruby/object:Gem::Version
|
61
87
|
version: '10'
|
62
88
|
type: :development
|
63
89
|
prerelease: false
|
64
90
|
version_requirements: !ruby/object:Gem::Requirement
|
65
91
|
requirements:
|
66
|
-
- - ~>
|
92
|
+
- - "~>"
|
67
93
|
- !ruby/object:Gem::Version
|
68
94
|
version: '10'
|
69
95
|
description: A ruby gem for validating credit card numbers
|
@@ -73,8 +99,9 @@ executables: []
|
|
73
99
|
extensions: []
|
74
100
|
extra_rdoc_files: []
|
75
101
|
files:
|
76
|
-
- .
|
77
|
-
- .
|
102
|
+
- ".gitignore"
|
103
|
+
- ".hound.yml"
|
104
|
+
- ".travis.yml"
|
78
105
|
- Changelog.md
|
79
106
|
- Gemfile
|
80
107
|
- LICENSE.txt
|
@@ -104,27 +131,29 @@ files:
|
|
104
131
|
- spec/models/credit_card.rb
|
105
132
|
- spec/string_spec.rb
|
106
133
|
- spec/test_helper.rb
|
107
|
-
homepage: http://
|
134
|
+
homepage: http://didww.github.io/credit_card_validations/
|
108
135
|
licenses:
|
109
136
|
- MIT
|
110
|
-
metadata:
|
137
|
+
metadata:
|
138
|
+
bug_tracker_uri: https://github.com/didww/credit_card_validations/issues
|
139
|
+
changelog_uri: https://github.com/didww/credit_card_validations/blob/master/Changelog.md
|
140
|
+
source_code_uri: https://github.com/didww/credit_card_validations
|
111
141
|
post_install_message:
|
112
142
|
rdoc_options: []
|
113
143
|
require_paths:
|
114
144
|
- lib
|
115
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
146
|
requirements:
|
117
|
-
- -
|
147
|
+
- - ">="
|
118
148
|
- !ruby/object:Gem::Version
|
119
149
|
version: '0'
|
120
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
151
|
requirements:
|
122
|
-
- -
|
152
|
+
- - ">="
|
123
153
|
- !ruby/object:Gem::Version
|
124
154
|
version: '0'
|
125
155
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.4.8
|
156
|
+
rubygems_version: 3.0.3
|
128
157
|
signing_key:
|
129
158
|
specification_version: 4
|
130
159
|
summary: gem should be used for credit card numbers validation, card brands detections,
|