From e0a11b377f7e351500edd930d957e9fd3ff4cab2 Mon Sep 17 00:00:00 2001 From: Jennifer Konikowski Date: Mon, 5 Aug 2024 14:49:22 -0400 Subject: [PATCH] fix small bug --- app/pace.rb | 8 ++++---- test/pace_test.rb | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/pace.rb b/app/pace.rb index 76aa90d..eb2593e 100644 --- a/app/pace.rb +++ b/app/pace.rb @@ -37,17 +37,17 @@ def initialize(type:, activity:, distance: nil, pace_length: nil, def print_pace "To #{activity} #{@distance} #{@pace_length} in " \ "#{time(@time_hours, @time_minutes, @time_seconds)}, " \ - "you need a pace of #{pace(@pace_minutes, @pace_seconds, @pace_length)}" + "you need a pace of #{pace(@pace_minutes, @pace_seconds, @pace_length)}." end def print_time "If you #{activity} #{@distance} #{@distance_length} with " \ "a pace of #{pace(@pace_minutes, @pace_seconds, @pace_length)}, " \ - "you'll finish in #{time(@time_hours, @time_minutes, @time_seconds)}" + "you'll finish in #{time(@time_hours, @time_minutes, @time_seconds)}." end def print_distance - "If you #{activity} a pace of of " \ + "If you #{activity} a pace of " \ "#{pace(@pace_minutes, @pace_seconds, @pace_length)}" \ " for #{time(@time_hours, @time_minutes, @time_seconds)}, " \ "you will go #{pluralize(distance, distance_length)}." @@ -56,7 +56,7 @@ def print_distance private def pluralize(number, text) - text = (number == 1) ? text : text + "s" + text = (number > 1.0) ? text + "s" : text "#{number} #{text}" end diff --git a/test/pace_test.rb b/test/pace_test.rb index 1e720d8..7d73c91 100644 --- a/test/pace_test.rb +++ b/test/pace_test.rb @@ -4,49 +4,49 @@ class TestPace < Minitest::Test def test_calculates_pace_run pace = Pace.new(type: "pace", activity: "run", distance: 5, pace_length: "mile", distance_length: "mile", time_hours: 0, time_minutes: 30, time_seconds: 0) - assert_equal "To run 5.0 mile in 0:30:00, you need a pace of 6:00/mile", pace.print_pace + assert_equal "To run 5.0 mile in 0:30:00, you need a pace of 6:00/mile.", pace.print_pace end def test_calculates_time_run pace = Pace.new(type: "time", activity: "run", distance: 5, pace_length: "mile", distance_length: "mile", pace_minutes: 6, pace_seconds: 0) - assert_equal "If you run 5.0 mile with a pace of 6:00/mile, you'll finish in 0:30:00", pace.print_time + assert_equal "If you run 5.0 mile with a pace of 6:00/mile, you'll finish in 0:30:00.", pace.print_time end def test_calculates_distance_run pace = Pace.new(type: "distance", activity: "run", pace_length: "mile", distance_length: "mile", pace_minutes: 6, pace_seconds: 0, time_hours: 0, time_minutes: 30, time_seconds: 0) - assert_equal "If you run a pace of of 6:00/mile for 0:30:00, you will go 5 miles.", pace.print_distance + assert_equal "If you run a pace of 6:00/mile for 0:30:00, you will go 5 miles.", pace.print_distance end def test_calculates_pace_swim skip "this has a bug" pace = Pace.new(type: "pace", activity: "swim", distance: 500, pace_length: "50yd", distance_length: "meter", time_hours: 0, time_minutes: 10, time_seconds: 0) - assert_equal "If you swim 500.0 meter with a pace of 2:00/50yd, you'll finish in 0:43:44", pace.print_pace + assert_equal "To swim 500 meters in 0:10:00, you need a pace of 0:54/50yd.", pace.print_pace end def test_calculates_time_swim pace = Pace.new(type: "time", activity: "swim", distance: 500, pace_length: "25yd", distance_length: "meter", pace_minutes: 2, pace_seconds: 0) - assert_equal "If you swim 500.0 meter with a pace of 2:00/25yd, you'll finish in 0:43:44", pace.print_time + assert_equal "If you swim 500.0 meter with a pace of 2:00/25yd, you'll finish in 0:43:44.", pace.print_time end def test_calculates_distance_swim skip "this has a bug" pace = Pace.new(type: "distance", activity: "swim", pace_length: "50m", distance_length: "meter", pace_minutes: 2, pace_seconds: 0, time_hours: 0, time_minutes: 10, time_seconds: 0) - assert_equal "If you swim a pace of of 2:00/50m for 0:10:00, you will go 500 meters.", pace.print_distance + assert_equal "If you swim a pace of 2:00/50m for 0:10:00, you will go 250 meters.", pace.print_distance end def test_calculates_pace_row skip "this has a bug" pace = Pace.new(type: "pace", activity: "row", distance: 2000, pace_length: "500m", distance_length: "meter", time_hours: 0, time_minutes: 10, time_seconds: 0) - assert_equal "To row 2000 m in 0:10:00, you need a pace of 2:30/500m", pace.print_pace + assert_equal "To row 2000 m in 0:10:00, you need a pace of 2:30/500m.", pace.print_pace end def test_calculates_time_row pace = Pace.new(type: "time", activity: "row", distance: 2, pace_length: "500meter", distance_length: "mile", pace_minutes: 2, pace_seconds: 30) - assert_equal "If you row 2.0 mile with a pace of 2:30/500meter, you'll finish in 0:08:02", pace.print_time + assert_equal "If you row 2.0 mile with a pace of 2:30/500meter, you'll finish in 0:08:02.", pace.print_time end def test_calculates_distance_row pace = Pace.new(type: "distance", activity: "row", pace_length: "500meter", distance_length: "mile", pace_minutes: 2, pace_seconds: 30, time_hours: 0, time_minutes: 10, time_seconds: 0) - assert_equal "If you row a pace of of 2:30/500meter for 0:10:00, you will go 6.44 miles.", pace.print_distance + assert_equal "If you row a pace of 2:30/500meter for 0:10:00, you will go 6.44 miles.", pace.print_distance end end