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."