Skip to content

Commit 66c5ebe

Browse files
authored
Merge pull request #936 from exercism/high-scores-v3
high-scores: Regenerate tests
2 parents 425ff89 + be6fcbf commit 66c5ebe

File tree

3 files changed

+12
-46
lines changed

3 files changed

+12
-46
lines changed

exercises/high-scores/.meta/solutions/high_scores.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ def latest
1515
scores.last
1616
end
1717

18-
def personal_top
19-
scores.sort.reverse.take(3)
20-
end
21-
22-
def report
23-
difference = "#{personal_best - latest} short of" if personal_best != latest
24-
25-
"Your latest score was #{latest}. That's #{difference} your personal best!".squeeze
18+
def personal_top_three
19+
scores.max(3)
2620
end
2721
end

exercises/high-scores/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Manage a game player's High Score list.
44

5-
Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score, the three highest scores, and a report on the difference between the last and the highest scores.
5+
Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score and the three highest scores.
66

77
In this exercise you're going to instantiate a class and add some instance methods. http://ruby-for-beginners.rubymonstas.org/writing_classes/initializers.html
88

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'minitest/autorun'
22
require_relative 'high_scores'
33

4-
# Common test data version: 2.0.0 7a386a2
4+
# Common test data version: 4.0.0 ad1f9c4
55
class HighScoresTest < Minitest::Test
66
def test_list_of_scores
77
# skip
@@ -24,66 +24,38 @@ def test_personal_best
2424
assert_equal expected, HighScores.new(scores).personal_best
2525
end
2626

27-
def test_personal_top
27+
def test_personal_top_three_from_a_list_of_scores
2828
skip
29-
scores = [50, 30, 10]
30-
expected = [50, 30, 10]
31-
assert_equal expected, HighScores.new(scores).personal_top
29+
scores = [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]
30+
expected = [100, 90, 70]
31+
assert_equal expected, HighScores.new(scores).personal_top_three
3232
end
3333

3434
def test_personal_top_highest_to_lowest
3535
skip
3636
scores = [20, 10, 30]
3737
expected = [30, 20, 10]
38-
assert_equal expected, HighScores.new(scores).personal_top
38+
assert_equal expected, HighScores.new(scores).personal_top_three
3939
end
4040

4141
def test_personal_top_when_there_is_a_tie
4242
skip
4343
scores = [40, 20, 40, 30]
4444
expected = [40, 40, 30]
45-
assert_equal expected, HighScores.new(scores).personal_top
45+
assert_equal expected, HighScores.new(scores).personal_top_three
4646
end
4747

4848
def test_personal_top_when_there_are_less_than_3
4949
skip
5050
scores = [30, 70]
5151
expected = [70, 30]
52-
assert_equal expected, HighScores.new(scores).personal_top
52+
assert_equal expected, HighScores.new(scores).personal_top_three
5353
end
5454

5555
def test_personal_top_when_there_is_only_one
5656
skip
5757
scores = [40]
5858
expected = [40]
59-
assert_equal expected, HighScores.new(scores).personal_top
60-
end
61-
62-
def test_personal_top_from_a_long_list
63-
skip
64-
scores = [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]
65-
expected = [100, 90, 70]
66-
assert_equal expected, HighScores.new(scores).personal_top
67-
end
68-
69-
def test_message_for_new_personal_best
70-
skip
71-
scores = [20, 40, 0, 30, 70]
72-
expected = "Your latest score was 70. That's your personal best!"
73-
assert_equal expected, HighScores.new(scores).report
74-
end
75-
76-
def test_message_when_latest_score_is_not_the_highest_score
77-
skip
78-
scores = [20, 100, 0, 30, 70]
79-
expected = "Your latest score was 70. That's 30 short of your personal best!"
80-
assert_equal expected, HighScores.new(scores).report
81-
end
82-
83-
def test_message_for_repeated_personal_best
84-
skip
85-
scores = [20, 70, 50, 70, 30]
86-
expected = "Your latest score was 30. That's 40 short of your personal best!"
87-
assert_equal expected, HighScores.new(scores).report
59+
assert_equal expected, HighScores.new(scores).personal_top_three
8860
end
8961
end

0 commit comments

Comments
 (0)