Sha256: b4adc30a58de4da182054d17666fcd122b37f2978c71e5f5c917cfee2fbc38a8
Contents?: true
Size: 821 Bytes
Versions: 2
Compression:
Stored size: 821 Bytes
Contents
require "test_helper" require "credit_card_detector/rule" module CreditCardDetector describe Rule do describe "#matches?" do let(:rule) { Rule.new(length: [8, 9], prefixes: [1234, 2345]) } it "matches when number has correct length AND starts from any prefix" do assert_equal rule.matches?(12345678), true assert_equal rule.matches?(234567890), true end it "doesn't match when number has incorrect length" do assert_equal rule.matches?(123), false assert_equal rule.matches?(""), false assert_equal rule.matches?(1234567890123), false end it "doesn't match when number doesn't start from any prefix" do assert_equal rule.matches?(01234567), false assert_equal rule.matches?(00000000), false end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
credit_card_detector-0.4 | spec/rule_spec.rb |
credit_card_detector-0.3 | spec/rule_spec.rb |