From 6566d956d4ec7bac909d5c27c8b7de518dfbe340 Mon Sep 17 00:00:00 2001 From: Ruben Espinosa Date: Mon, 11 Mar 2013 23:55:14 -0500 Subject: [PATCH] new unit tests --- .gitignore | 1 + README.md | 8 +++++--- spec/test_payment_spec.rb | 28 +++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d87d4be..a955cfa 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ spec/reports test/tmp test/version_tmp tmp +.DS_Store diff --git a/README.md b/README.md index 7eb2320..28580c3 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,6 @@ anticipated_variable_payment_amortization (periods, amount, rate, payment) #### Amortization with fixed payment due due_fixed_payment_amortization (periods, amount, rate, payment) -#### Variable payment amortization anticipated -anticipated_fixed_payment_amortization (periods, amount, rate, payment) - $ due_fixed_payment_amortization(5,10000,1.8,2109) $ [{:period=>0, :monthly_payment=>nil, :interest=>nil, :payment=>nil, :balance=>10000}, {:period=>1, :payment=>2109, :interest=>18000.0, :monthly_payment=>-15891.0, :balance=>25891.0}, @@ -70,6 +67,11 @@ anticipated_fixed_payment_amortization (periods, amount, rate, payment) {:period=>4, :payment=>2109, :interest=>350948.232, :monthly_payment=>-348839.232, :balance=>543810.4720000001}, {:period=>5, :payment=>2109, :interest=>978858.8496000002, :monthly_payment=>-976749.8496000002, :balance=>1520560.3216000004}] + +#### Variable payment amortization anticipated +anticipated_fixed_payment_amortization (periods, amount, rate, payment) + + #### Find future given the present value future_given_present (present_value, interest, term) diff --git a/spec/test_payment_spec.rb b/spec/test_payment_spec.rb index e9307e6..7bf5e79 100644 --- a/spec/test_payment_spec.rb +++ b/spec/test_payment_spec.rb @@ -2,11 +2,8 @@ require 'spec_helper' describe "fixed payment test" do - it 'should be the monthly payment' do - annuity_given_present(100000000, 0.0144594763, 180).should eq(1563975.1395) - end end @@ -15,3 +12,28 @@ variable_payment(10000000.0,40).should eq(250000) end end + +describe "due variable payment amortization" do + it "should be a hash of payments" do + due_variable_payment_amortization(5,10000,1.8,2000).should be_an(Array) + end +end + +describe "anticipated vabiable payment amortization" do + it "should be a hash of payments" do + anticipated_variable_payment_amortization(5,10000,1.8,2000).should be_an(Array) + end +end + +describe "due fixed payment amortization" do + it "should be a hash of payments" do + due_fixed_payment_amortization(5,10000,1.8,2000).should be_an(Array) + end +end + +describe "anticipated fixed payment amortization" do + it "should be a hash of payments" do + anticipated_fixed_payment_amortization(5,10000,1.8,2000).should be_an(Array) + end +end +