Sha256: 8698e29a4ebe051d3bd7744ce5dafe75af710a6912ccc24b5501fe51434ad75e

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

describe CreditCardValidation do
  before do
    @validator = CreditCardValidation::Validator.new
  end

  describe "when asked about validity of a AMEX card" do
    it "should respond true for a valid card" do
      @validator.card = "378282246310005"
      @validator.must_be :valid?
    end

    it "should respond false for a invalid card" do
      @validator.card = "37828224631000"
      @validator.wont_be :valid?
    end
  end

  describe "when asked about validity of a Discover card" do
    it "should respond true for a valid card" do
      @validator.card = "6011111111111117"
      @validator.must_be :valid?
    end

    it "should respond false for a invalid card" do
      @validator.card = "601111111111111"
      @validator.wont_be :valid?
    end
  end

  describe "when asked about validity of a MasterCard card" do
    it "should respond true for a valid card" do
      @validator.card = "5105105105105100"
      @validator.must_be :valid?
    end

    it "should respond false for a invalid card" do
      @validator.card = "5105105105105106"
      @validator.wont_be :valid?
    end

    it "should respond false for a invalid card" do
      @validator.card = "510510510510510"
      @validator.wont_be :valid?
    end
  end

  describe "when asked about validity of a VISA card" do
    it "should respond true for a valid card" do
      @validator.card = "4111111111111111"
      @validator.must_be :valid?
    end

    it "should respond true for a valid card" do
      @validator.card = "4012888888881881"
      @validator.must_be :valid?
    end

    it "should respond false for a invalid card" do
      @validator.card = "4111111111111"
      @validator.wont_be :valid?
    end
  end

  describe "when asked about validity of a Unkown card" do
    it "should respond false for a invalid card" do
      @validator.card = "9111111111111111"
      @validator.wont_be :valid?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
credit_card_validation-1.0.2 spec/credit_card_validation_spec.rb
credit_card_validation-1.0.1 spec/credit_card_validation_spec.rb
credit_card_validation-1.0.0 spec/credit_card_validation_spec.rb
credit_card_validation-0.0.1 spec/credit_card_validation_spec.rb