credit_card_validations 3.5.0 → 5.0.0
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 +5 -5
- data/.github/workflows/build.yml +30 -0
- data/.gitignore +3 -0
- data/Changelog.md +3 -1
- data/Gemfile +2 -1
- data/README.md +4 -8
- data/credit_card_validations.gemspec +12 -5
- data/lib/credit_card_validations/version.rb +1 -1
- data/lib/data/brands.yaml +29 -2
- 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 +0 -5
- data/spec/string_spec.rb +13 -13
- data/spec/test_helper.rb +1 -3
- metadata +53 -24
- data/.travis.yml +0 -19
- data/gemfiles/rails1-4.gemfile +0 -11
- data/gemfiles/rails5.gemfile +0 -10
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: '03328c061e5430470ceb2f0d4af1359d58aa272c370c16eb3484574c39e97e63'
         | 
| 4 | 
            +
              data.tar.gz: e9b394824f0faeba5cade67212f126c4589bd4ba825de1cb1f2f079f9d6cad72
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7a51d59395f02c3cfb2d3b5ab68bf628f97eb71f711871ea6e8994372f54b7fa366be11869ac7b7568acae37399f0424446028a1272ad7c6823d7ee489a5df05
         | 
| 7 | 
            +
              data.tar.gz: 34b9d7bef2e7969c0dfd88bdc0310831a1875abf14e434affdd603f7eed0f11067dc1dab9a9bce8c793f5792e0091abd5f7b7f8e70420f4f1705d1dff064eceb
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            name: CI
         | 
| 2 | 
            +
            on:
         | 
| 3 | 
            +
              pull_request:
         | 
| 4 | 
            +
              push:
         | 
| 5 | 
            +
                branches:
         | 
| 6 | 
            +
                - master
         | 
| 7 | 
            +
            jobs:
         | 
| 8 | 
            +
              test:
         | 
| 9 | 
            +
                name: Tests with Ruby ${{ matrix.ruby }} Rails ${{ matrix.rails }}
         | 
| 10 | 
            +
                runs-on: ubuntu-latest
         | 
| 11 | 
            +
                strategy:
         | 
| 12 | 
            +
                  matrix:
         | 
| 13 | 
            +
                    ruby-version:
         | 
| 14 | 
            +
                    - 2.7
         | 
| 15 | 
            +
                    - 3.0
         | 
| 16 | 
            +
                    rails:
         | 
| 17 | 
            +
                    - '6.1.5'
         | 
| 18 | 
            +
                    - '7.0.2.3'
         | 
| 19 | 
            +
                env:
         | 
| 20 | 
            +
                  RAILS_VERSION: ${{ matrix.rails }}
         | 
| 21 | 
            +
                steps:
         | 
| 22 | 
            +
                - uses: actions/checkout@v2
         | 
| 23 | 
            +
                - uses: actions/setup-ruby@v1
         | 
| 24 | 
            +
                  with:
         | 
| 25 | 
            +
                    ruby-version: ${{ matrix.ruby-version }}
         | 
| 26 | 
            +
                - name: Run tests
         | 
| 27 | 
            +
                  run: |
         | 
| 28 | 
            +
                    gem install bundler -v '< 2'
         | 
| 29 | 
            +
                    bundle install
         | 
| 30 | 
            +
                    bundle exec rake
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Changelog.md
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    | @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            source 'https://rubygems.org'
         | 
| 2 2 | 
             
            group :test do
         | 
| 3 | 
            -
              gem ' | 
| 3 | 
            +
              gem 'activemodel', ENV['RAILS_VERSION'], require: false
         | 
| 4 | 
            +
              gem 'activesupport', ENV['RAILS_VERSION'], require: false
         | 
| 4 5 | 
             
            end
         | 
| 5 6 | 
             
            # Specify your gem's dependencies in credit_card_validations.gemspec
         | 
| 6 7 | 
             
            gemspec
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,11 +1,7 @@ | |
| 1 1 | 
             
            # CreditCardValidations
         | 
| 2 2 |  | 
| 3 | 
            -
            [](https://travis-ci.org/Fivell/credit_card_validations)
         | 
| 4 | 
            -
            [](https://gemnasium.com/Fivell/credit_card_validations)
         | 
| 5 | 
            -
            [](https://coveralls.io/r/Fivell/credit_card_validations)
         | 
| 6 | 
            -
            [](https://codeclimate.com/github/Fivell/credit_card_validations)
         | 
| 7 3 | 
             
            [](https://rubygems.org/gems/credit_card_validations)
         | 
| 8 | 
            -
            [](http:// | 
| 4 | 
            +
            [](http://didww.mit-license.org)
         | 
| 9 5 |  | 
| 10 6 |  | 
| 11 7 | 
             
            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.
         | 
| @@ -57,7 +53,7 @@ The following issuing institutes are accepted: | |
| 57 53 |  | 
| 58 54 |  | 
| 59 55 |  | 
| 60 | 
            -
            The following are supported with  | 
| 56 | 
            +
            The following are supported with plugins
         | 
| 61 57 |  | 
| 62 58 | 
             
            |    Name   |    Key     | 
         | 
| 63 59 | 
             
            ---------------------   | ------------| 
         | 
| @@ -131,7 +127,7 @@ CreditCardValidations::Detector.delete_brand(:maestro) | |
| 131 127 | 
             
            CreditCardValidations::Detector.new(@credit_card_number).valid_luhn?
         | 
| 132 128 | 
             
            #or
         | 
| 133 129 | 
             
            CreditCardValidations::Luhn.valid?(@credit_card_number)
         | 
| 134 | 
            -
            ``` | 
| 130 | 
            +
            ```
         | 
| 135 131 |  | 
| 136 132 | 
             
            ### Generate credit card numbers that pass validation
         | 
| 137 133 |  | 
| @@ -142,7 +138,7 @@ CreditCardValidations::Factory.random(:maestro) | |
| 142 138 | 
             
            # => "6010430241237266856"
         | 
| 143 139 | 
             
            ```
         | 
| 144 140 |  | 
| 145 | 
            -
            ### Plugins | 
| 141 | 
            +
            ### Plugins
         | 
| 146 142 |  | 
| 147 143 | 
             
            ```ruby
         | 
| 148 144 | 
             
            require 'credit_card_validations/plugins/en_route'
         | 
| @@ -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,11 +25,12 @@ Gem::Specification.new do |gem| | |
| 19 25 | 
             
              gem.require_paths = ["lib"]
         | 
| 20 26 |  | 
| 21 27 |  | 
| 22 | 
            -
              gem.add_dependency "activemodel", ">=  | 
| 23 | 
            -
              gem.add_dependency "activesupport", ">=  | 
| 28 | 
            +
              gem.add_dependency "activemodel", ">= 5.2", "< 7.1"
         | 
| 29 | 
            +
              gem.add_dependency "activesupport", ">= 5.2", "< 7.1"
         | 
| 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 | 
            +
              gem.add_development_dependency 'byebug'
         | 
| 29 36 | 
             
            end
         | 
    
        data/lib/data/brands.yaml
    CHANGED
    
    | @@ -197,7 +197,10 @@ | |
| 197 197 | 
             
                - '637187'
         | 
| 198 198 | 
             
                - '637529'
         | 
| 199 199 | 
             
                - '639'
         | 
| 200 | 
            -
                - ' | 
| 200 | 
            +
                - '640'
         | 
| 201 | 
            +
                - '641'
         | 
| 202 | 
            +
                - '642'
         | 
| 203 | 
            +
                - '643'
         | 
| 201 204 | 
             
                - '670'
         | 
| 202 205 | 
             
                - '671'
         | 
| 203 206 | 
             
                - '672'
         | 
| @@ -477,7 +480,31 @@ | |
| 477 480 | 
             
                - 16
         | 
| 478 481 | 
             
                - 19
         | 
| 479 482 | 
             
                :prefixes:
         | 
| 480 | 
            -
                - ' | 
| 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'
         | 
| 481 508 | 
             
                - '644'
         | 
| 482 509 | 
             
                - '645'
         | 
| 483 510 | 
             
                - '646'
         | 
    
        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
         | 
| @@ -43,14 +43,9 @@ | |
| 43 43 | 
             
            - 3777 5274 9896 404
         | 
| 44 44 | 
             
            - 3782 8224 6310 005
         | 
| 45 45 | 
             
            :discover:
         | 
| 46 | 
            -
            - 6011 1111 1111 1117
         | 
| 47 46 | 
             
            - 6011 0009 9013 9424
         | 
| 48 47 | 
             
            - 6011 0000 0000 0004
         | 
| 49 48 | 
             
            - 6011 0004 0000 0000
         | 
| 50 | 
            -
            - 6011 1532 1637 1980
         | 
| 51 | 
            -
            - 6011 6011 6011 6611
         | 
| 52 | 
            -
            - 6011 6874 8256 4166
         | 
| 53 | 
            -
            - 6011 8148 3690 5651
         | 
| 54 49 | 
             
            :maestro:
         | 
| 55 50 | 
             
            - 6759 6498 2643 8453
         | 
| 56 51 | 
             
            - 5641 8200 0000 0005
         | 
    
        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
         | 
    
        data/spec/test_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: credit_card_validations
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 5.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Igor
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2022-04-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activemodel
         | 
| @@ -16,40 +16,54 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: ' | 
| 20 | 
            -
                - - " | 
| 19 | 
            +
                    version: '5.2'
         | 
| 20 | 
            +
                - - "<"
         | 
| 21 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            -
                    version: ' | 
| 22 | 
            +
                    version: '7.1'
         | 
| 23 23 | 
             
              type: :runtime
         | 
| 24 24 | 
             
              prerelease: false
         | 
| 25 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 26 | 
             
                requirements:
         | 
| 27 27 | 
             
                - - ">="
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: ' | 
| 30 | 
            -
                - - " | 
| 29 | 
            +
                    version: '5.2'
         | 
| 30 | 
            +
                - - "<"
         | 
| 31 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            -
                    version: ' | 
| 32 | 
            +
                    version: '7.1'
         | 
| 33 33 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 34 34 | 
             
              name: activesupport
         | 
| 35 35 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 36 | 
             
                requirements:
         | 
| 37 37 | 
             
                - - ">="
         | 
| 38 38 | 
             
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            -
                    version: ' | 
| 40 | 
            -
                - - " | 
| 39 | 
            +
                    version: '5.2'
         | 
| 40 | 
            +
                - - "<"
         | 
| 41 41 | 
             
                  - !ruby/object:Gem::Version
         | 
| 42 | 
            -
                    version: ' | 
| 42 | 
            +
                    version: '7.1'
         | 
| 43 43 | 
             
              type: :runtime
         | 
| 44 44 | 
             
              prerelease: false
         | 
| 45 45 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 46 46 | 
             
                requirements:
         | 
| 47 47 | 
             
                - - ">="
         | 
| 48 48 | 
             
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            -
                    version: ' | 
| 50 | 
            -
                - - " | 
| 49 | 
            +
                    version: '5.2'
         | 
| 50 | 
            +
                - - "<"
         | 
| 51 51 | 
             
                  - !ruby/object:Gem::Version
         | 
| 52 | 
            -
                    version: ' | 
| 52 | 
            +
                    version: '7.1'
         | 
| 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
         | 
| 53 67 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 54 68 | 
             
              name: mocha
         | 
| 55 69 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -78,6 +92,20 @@ dependencies: | |
| 78 92 | 
             
                - - "~>"
         | 
| 79 93 | 
             
                  - !ruby/object:Gem::Version
         | 
| 80 94 | 
             
                    version: '10'
         | 
| 95 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 96 | 
            +
              name: byebug
         | 
| 97 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 98 | 
            +
                requirements:
         | 
| 99 | 
            +
                - - ">="
         | 
| 100 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 101 | 
            +
                    version: '0'
         | 
| 102 | 
            +
              type: :development
         | 
| 103 | 
            +
              prerelease: false
         | 
| 104 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
                requirements:
         | 
| 106 | 
            +
                - - ">="
         | 
| 107 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 108 | 
            +
                    version: '0'
         | 
| 81 109 | 
             
            description: A ruby gem for validating credit card numbers
         | 
| 82 110 | 
             
            email:
         | 
| 83 111 | 
             
            - fedoronchuk@gmail.com
         | 
| @@ -85,16 +113,15 @@ executables: [] | |
| 85 113 | 
             
            extensions: []
         | 
| 86 114 | 
             
            extra_rdoc_files: []
         | 
| 87 115 | 
             
            files:
         | 
| 116 | 
            +
            - ".github/workflows/build.yml"
         | 
| 117 | 
            +
            - ".gitignore"
         | 
| 88 118 | 
             
            - ".hound.yml"
         | 
| 89 | 
            -
            - ".travis.yml"
         | 
| 90 119 | 
             
            - Changelog.md
         | 
| 91 120 | 
             
            - Gemfile
         | 
| 92 121 | 
             
            - LICENSE.txt
         | 
| 93 122 | 
             
            - README.md
         | 
| 94 123 | 
             
            - Rakefile
         | 
| 95 124 | 
             
            - credit_card_validations.gemspec
         | 
| 96 | 
            -
            - gemfiles/rails1-4.gemfile
         | 
| 97 | 
            -
            - gemfiles/rails5.gemfile
         | 
| 98 125 | 
             
            - lib/active_model/credit_card_number_validator.rb
         | 
| 99 126 | 
             
            - lib/credit_card_validations.rb
         | 
| 100 127 | 
             
            - lib/credit_card_validations/detector.rb
         | 
| @@ -116,11 +143,14 @@ files: | |
| 116 143 | 
             
            - spec/models/credit_card.rb
         | 
| 117 144 | 
             
            - spec/string_spec.rb
         | 
| 118 145 | 
             
            - spec/test_helper.rb
         | 
| 119 | 
            -
            homepage: http:// | 
| 146 | 
            +
            homepage: http://didww.github.io/credit_card_validations/
         | 
| 120 147 | 
             
            licenses:
         | 
| 121 148 | 
             
            - MIT
         | 
| 122 | 
            -
            metadata: | 
| 123 | 
            -
             | 
| 149 | 
            +
            metadata:
         | 
| 150 | 
            +
              bug_tracker_uri: https://github.com/didww/credit_card_validations/issues
         | 
| 151 | 
            +
              changelog_uri: https://github.com/didww/credit_card_validations/blob/master/Changelog.md
         | 
| 152 | 
            +
              source_code_uri: https://github.com/didww/credit_card_validations
         | 
| 153 | 
            +
            post_install_message:
         | 
| 124 154 | 
             
            rdoc_options: []
         | 
| 125 155 | 
             
            require_paths:
         | 
| 126 156 | 
             
            - lib
         | 
| @@ -135,9 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 135 165 | 
             
                - !ruby/object:Gem::Version
         | 
| 136 166 | 
             
                  version: '0'
         | 
| 137 167 | 
             
            requirements: []
         | 
| 138 | 
            -
             | 
| 139 | 
            -
             | 
| 140 | 
            -
            signing_key: 
         | 
| 168 | 
            +
            rubygems_version: 3.1.6
         | 
| 169 | 
            +
            signing_key:
         | 
| 141 170 | 
             
            specification_version: 4
         | 
| 142 171 | 
             
            summary: gem should be used for credit card numbers validation, card brands detections,
         | 
| 143 172 | 
             
              luhn checks
         | 
    
        data/.travis.yml
    DELETED
    
    | @@ -1,19 +0,0 @@ | |
| 1 | 
            -
            language: ruby
         | 
| 2 | 
            -
            rvm:
         | 
| 3 | 
            -
              - 2.1.10
         | 
| 4 | 
            -
              - 2.2.8
         | 
| 5 | 
            -
              - 2.3.5
         | 
| 6 | 
            -
              - jruby-9.1.15.0
         | 
| 7 | 
            -
            gemfile:
         | 
| 8 | 
            -
              - gemfiles/rails1-4.gemfile
         | 
| 9 | 
            -
              - gemfiles/rails5.gemfile
         | 
| 10 | 
            -
            matrix:
         | 
| 11 | 
            -
              exclude:
         | 
| 12 | 
            -
                - gemfile: gemfiles/rails5.gemfile
         | 
| 13 | 
            -
                  rvm: 2.1.10
         | 
| 14 | 
            -
                - gemfile: gemfiles/rails5.gemfile
         | 
| 15 | 
            -
                  rvm: jruby-9.1.6.0
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            before_install:
         | 
| 18 | 
            -
              - gem update --system # use the very latest Rubygems
         | 
| 19 | 
            -
              - gem install bundler # use the very latest Bundler
         | 
    
        data/gemfiles/rails1-4.gemfile
    DELETED
    
    | @@ -1,11 +0,0 @@ | |
| 1 | 
            -
            source "https://rubygems.org"
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            gem "activemodel", ">= 3", '< 5'
         | 
| 4 | 
            -
            gem "activesupport", ">= 3", '< 5'
         | 
| 5 | 
            -
            group :test do
         | 
| 6 | 
            -
              gem 'tins', '< 1.3.4', platforms: [:ruby_19, :jruby]
         | 
| 7 | 
            -
              gem 'term-ansicolor', '~> 1.3.0', platforms: [:ruby_19, :jruby]
         | 
| 8 | 
            -
              gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
         | 
| 9 | 
            -
            end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            gemspec :path => "../"
         | 
    
        data/gemfiles/rails5.gemfile
    DELETED