Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "./savings_required_calculator.rb"
- describe SavingsRequiredCalculator do
- let(:input) {
- {
- :first_name_1 => "Robert",
- :first_name_2 => "Ana",
- :last_name => "Harwood",
- :age_1 => 50,
- :age_2 => 41,
- :retirement_age_1 => 62,
- :retirement_age_2 => 53,
- :years_to_retirement => 12,
- :target_retirement_income => 20000.00,
- :combined_social_security => 4000.00,
- :combined_pensions => 3500.00,
- :other_income => 0.00,
- :average_inflation_rate => 3.10,
- :average_rate_of_return => 5.00,
- :current_portfolio => 2400000.00
- }
- }
- it "raises error if all paramaters were not specified" do
- expect {SavingsRequiredCalculator.new({}) }.to raise_error("Invalid Input")
- end
- it "successfully initializes if all arguments supplied" do
- expect(SavingsRequiredCalculator.new(input).class).to eq(SavingsRequiredCalculator)
- end
- it "calculates the Annual Savings to Retire at expected Year" do
- expect(SavingsRequiredCalculator.new(input).annual_savings_to_retire).to eq(204736.84)
- end
- it "calculates the shortfall / excess" do
- expect(SavingsRequiredCalculator.new(input).shortfall).to eq(-3896842.11)
- end
- it "calculates the shortfall / excess" do
- expect(SavingsRequiredCalculator.new(input).summary).to eq("You are planning to retire in approximately 12 years and your current savings are approximately
- $2,400,000.00\nThe monthly income we are targeting for retirement is $20,000.00 in todays dollars. After adjusting for a 3.1% inflation rate we calculate that your will need approximately $27,440.00 per month.\n\nWe recommend a portfolio size of $6,296,842.11 to support your income needs. You will need to save an average of $204,736.84
- for the next 12 years")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement