Sha256: 485091b3bcbbbad34bf8c2262cab2a48055df3afe5420db1a67159a730339839
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'helper' class TestBankValidator < MiniTest::Test class TestUser include ActiveModel::Validations validates :iban, iban: true attr_accessor :iban def initialize(attributes = {}) @iban = attributes[:iban] end def save if valid? return true else return false end end def self.create(attributes = {}) new(attributes).save end def iban @iban end end should "not save if the iban is too short" do assert_equal false, TestUser.create(iban: "GB82WEST") end should "save if the iban is at least 16 characters" do assert_equal true, TestUser.create(iban: "GB82WEST12345698765432") end should "returns false if the iban does not leave a remainder of 1 when divided by 97" do assert_equal false, TestUser.create(iban: "GB82WEST123456987654Df") end should "returns true if the iban returns a remainder of 1 when divided by 97" do assert_equal true, TestUser.create(iban: "GB82WEST12345698765432") end should "work for different IBAN formats" do #Belgium assert_equal true, TestUser.create(iban: "BE62510007547061") #Bulgaria assert_equal true, TestUser.create(iban: "BG80BNBG96611020345678") #Germany assert_equal true, TestUser.create(iban: "DE89370400440532013000") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bank-validator-0.0.6 | test/test_bank-validator.rb |
bank-validator-0.0.5 | test/test_bank-validator.rb |