-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHW1_Part2_Tests.rb
82 lines (69 loc) · 2.05 KB
/
HW1_Part2_Tests.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require 'test/unit'
require './HW1_Part2'
class TestRockPaperScissors < Test::Unit::TestCase
def test_cant_have_three_players
assert_raise(WrongNumberOfPlayersError) do
rps_game_winner([["Armando", "P"],["Dave", "S"],["David E.", "R"]])
end
end
def test_cant_have_one_player
assert_raise(WrongNumberOfPlayersError) do
rps_game_winner([["Armando", "P"]])
end
end
def test_no_such_strategy
assert_raise(NoSuchStrategyError) do
rps_game_winner([["Armando", "P"], ["Dave", "D"]])
end
end
def test_scissors_beat_paper
assert_equal rps_game_winner([["Armando", "P"], ["Dave", "S"]]), ["Dave", "S"]
end
def test_paper_beats_rock
assert_equal rps_game_winner([["Richard", "R"], ["Armando", "P"]]), ["Armando", "P"]
end
def test_rock_beats_scissors
assert_equal rps_game_winner([["Dave", "S"], ["Richard", "R"]]), ["Richard", "R"]
end
def test_same_strategy
assert_equal rps_game_winner([["Armando", "P"], ["Dave", "P"]]), ["Armando", "P"]
end
def test_case_insensitive
assert_equal rps_game_winner([["Dave", "s"], ["Richard", "r"]]), ["Richard", "r"]
end
def test_integration_there_can_be_a_tournament
assert_equal rps_tournament_winner(
[
[
[
["Armando", "P"], ["Dave", "S"]
],
[
["Richard", "R"], ["Michael", "S"] ]
],
[
[
["Allen", "S"], ["Omer", "P"]
],
[
["David E.", "R"], ["Richard X.", "P"]
]
]
]), ["Richard", "R"]
end
def test_tournament_returns_a_winner_for_simple_tournament
assert_equal rps_tournament_winner(
[
[
["Armando", "P"], ["Dave", "S"]
],
[
["Richard", "R"], ["Michael", "S"]
]
]
), [ "Richard", "R" ]
end
def test_tournament_returns_a_winner_for_a_more_complicated_tournament
assert_equal rps_tournament_winner([ [ "Armando", "S" ], [ "Dave", "R" ] ]), [ "Dave", "R" ]
end
end