From a263bb7d44c88c7fae4293f38d50c3cebefadc8f Mon Sep 17 00:00:00 2001 From: Ari Salas Date: Mon, 15 May 2017 20:55:59 +0000 Subject: [PATCH] Done. --- how_old_are_you.rb | 8 ++++++++ spec/current_age_for_birth_year_spec.rb | 6 +++++- spec/how_old_are_you.rb | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 how_old_are_you.rb create mode 100644 spec/how_old_are_you.rb diff --git a/how_old_are_you.rb b/how_old_are_you.rb new file mode 100644 index 0000000..6d46351 --- /dev/null +++ b/how_old_are_you.rb @@ -0,0 +1,8 @@ +require_relative './current_age_for_birth_year.rb' + +puts "What year were you born?" +birth_year = gets.to_i + +users_age = current_age_for_birth_year(birth_year) + +puts "You are: " "+ users_age.to_s + " " years old." diff --git a/spec/current_age_for_birth_year_spec.rb b/spec/current_age_for_birth_year_spec.rb index 7d0b09b..5209d77 100644 --- a/spec/current_age_for_birth_year_spec.rb +++ b/spec/current_age_for_birth_year_spec.rb @@ -3,7 +3,11 @@ describe "current_age_for_birth_year method" do it "returns the age of a person based on the year of birth" do age_of_person = current_age_for_birth_year(1984) - + expect(age_of_person).to eq(32) end end + +def current_age_for_birth_year (birth_year) + 2016 - birth_year +end diff --git a/spec/how_old_are_you.rb b/spec/how_old_are_you.rb new file mode 100644 index 0000000..6d46351 --- /dev/null +++ b/spec/how_old_are_you.rb @@ -0,0 +1,8 @@ +require_relative './current_age_for_birth_year.rb' + +puts "What year were you born?" +birth_year = gets.to_i + +users_age = current_age_for_birth_year(birth_year) + +puts "You are: " "+ users_age.to_s + " " years old."