Sha256: bd08a7ecce4fed9b886270b2cb5f27875417313c820cc88a4f3a7b04ce9339d4

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require_relative 'test_helper'
require 'credit_card_validations/string'

describe "String ext" do

  let(:mastercard) {
    CreditCardValidations::Factory.random(:mastercard)
  }

  let(:visa) {
    CreditCardValidations::Factory.random(:visa)
  }

  let(:invalid) {
    INVALID_NUMBERS.sample
  }

  it "should allow detect brand for mastercard" do

    mastercard.credit_card_brand.must_equal :mastercard
    mastercard.credit_card_brand_name.must_equal 'MasterCard'
    mastercard.valid_credit_card_brand?(:mastercard).must_equal true
    mastercard.valid_credit_card_brand?('MasterCard').must_equal true
    mastercard.valid_credit_card_brand?(:visa, :amex).must_equal false
  end

  it "should allow detect brand for visa" do

    visa.credit_card_brand.must_equal :visa
    visa.credit_card_brand_name.must_equal 'Visa'
    visa.valid_credit_card_brand?(:mastercard).must_equal false
    visa.valid_credit_card_brand?(:visa, :amex).must_equal true
  end

  it "should not allow detect brand for invalid card" do

    invalid.credit_card_brand.must_be_nil
    invalid.credit_card_brand_name.must_be_nil
    invalid.valid_credit_card_brand?(:mastercard).must_equal false
    invalid.valid_credit_card_brand?(:visa, :amex).must_equal false
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
credit_card_validations-2.0.2 spec/string_spec.rb
credit_card_validations-2.0.1 spec/string_spec.rb
credit_card_validations-2.0.0 spec/string_spec.rb