Advertisement
Guest User

Untitled

a guest
May 24th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. require "./savings_required_calculator.rb"
  2.  
  3. describe SavingsRequiredCalculator do
  4.  
  5. let(:input) {
  6. {
  7. :first_name_1 => "Robert",
  8. :first_name_2 => "Ana",
  9. :last_name => "Harwood",
  10. :age_1 => 50,
  11. :age_2 => 41,
  12. :retirement_age_1 => 62,
  13. :retirement_age_2 => 53,
  14. :years_to_retirement => 12,
  15. :target_retirement_income => 20000.00,
  16. :combined_social_security => 4000.00,
  17. :combined_pensions => 3500.00,
  18. :other_income => 0.00,
  19. :average_inflation_rate => 3.10,
  20. :average_rate_of_return => 5.00,
  21. :current_portfolio => 2400000.00
  22. }
  23. }
  24.  
  25. it "raises error if all paramaters were not specified" do
  26. expect {SavingsRequiredCalculator.new({}) }.to raise_error("Invalid Input")
  27. end
  28.  
  29. it "successfully initializes if all arguments supplied" do
  30. expect(SavingsRequiredCalculator.new(input).class).to eq(SavingsRequiredCalculator)
  31. end
  32.  
  33. it "calculates the Annual Savings to Retire at expected Year" do
  34. expect(SavingsRequiredCalculator.new(input).annual_savings_to_retire).to eq(204736.84)
  35. end
  36.  
  37. it "calculates the shortfall / excess" do
  38. expect(SavingsRequiredCalculator.new(input).shortfall).to eq(-3896842.11)
  39. end
  40.  
  41. it "calculates the shortfall / excess" do
  42. expect(SavingsRequiredCalculator.new(input).summary).to eq("You are planning to retire in approximately 12 years and your current savings are approximately
  43. $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
  44. for the next 12 years")
  45. end
  46.  
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement