spec/account_spec.rb in banktools-se-0.2.0 vs spec/account_spec.rb in banktools-se-0.3.0

- old
+ new

@@ -11,17 +11,17 @@ describe "#valid?" do it "should be true with no errors" do account = BankTools::SE::Account.new("foo") - account.stub!(:errors).and_return([]) + account.stub(:errors).and_return([]) account.should be_valid end it "should be false with errors" do account = BankTools::SE::Account.new("foo") - account.stub!(:errors).and_return([:error]) + account.stub(:errors).and_return([:error]) account.should_not be_valid end end @@ -76,10 +76,16 @@ it "should include :too_short for numbers shorter than the bank allows" do BankTools::SE::Account.new("11007").errors.should include(BankTools::SE::Errors::TOO_SHORT) end + it "should not include :too_short for Swedbank/Sparbanker numbers that can be zerofilled" do + BankTools::SE::Account.new("8000-2-00000000").errors.should_not include(BankTools::SE::Errors::TOO_SHORT) + BankTools::SE::Account.new("9300-2-00000000").errors.should_not include(BankTools::SE::Errors::TOO_SHORT) + BankTools::SE::Account.new("9570-2-00000000").errors.should_not include(BankTools::SE::Errors::TOO_SHORT) + end + it "should include :too_long for numbers longer than the bank allows" do BankTools::SE::Account.new("1100000000007").errors.should include(BankTools::SE::Errors::TOO_LONG) end it "should not include :too_long for Swedbank/Sparbanker numbers with clearing checksum" do @@ -157,9 +163,14 @@ BankTools::SE::Account.new("8000-2-0000000000").normalize.should == "8000-2-0000000000" end it "should not attempt to normalize invalid numbers" do account = BankTools::SE::Account.new(" 1-2-3 ").normalize.should == " 1-2-3 " + end + + it "should prepend zeroes to the serial number if necessary" do + BankTools::SE::Account.new("8000-2-80000003").normalize.should == "8000-2-0080000003" + BankTools::SE::Account.new("8000-2-8000000003").normalize.should == "8000-2-8000000003" end end end