1
exercism fetch ruby kindergarten-garden

kindergarten_garden_test.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
require 'minitest/autorun'
require_relative 'kindergarten_garden'

class GardenTest < Minitest::Test
  def test_alices_garden
    garden = Garden.new("RC\nGG")
    assert_equal [:radishes, :clover, :grass, :grass], garden.alice
  end

  def test_different_garden_for_alice
    skip
    garden = Garden.new("VC\nRC")
    assert_equal [:violets, :clover, :radishes, :clover], garden.alice
  end

  def test_bobs_garden
    skip
    garden = Garden.new("VVCG\nVVRC")
    assert_equal [:clover, :grass, :radishes, :clover], garden.bob
  end

  def test_bob_and_charlies_gardens
    skip
    garden = Garden.new("VVCCGG\nVVCCGG")
    assert_equal [:clover, :clover, :clover, :clover], garden.bob
    assert_equal [:grass, :grass, :grass, :grass], garden.charlie
  end
end

class TestFullGarden < Minitest::Test
  def setup
    skip
    diagram = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"
    @garden = Garden.new(diagram)
  end

  attr_reader :garden

  def test_alice
    skip
    assert_equal [:violets, :radishes, :violets, :radishes], garden.alice
  end

  def test_bob
    skip
    assert_equal [:clover, :grass, :clover, :clover], garden.bob
  end

  def test_charlie
    skip
    assert_equal [:violets, :violets, :clover, :grass], garden.charlie
  end

  def test_david
    skip
    assert_equal [:radishes, :violets, :clover, :radishes], garden.david
  end

  def test_eve
    skip
    assert_equal [:clover, :grass, :radishes, :grass], garden.eve
  end

  def test_fred
    skip
    assert_equal [:grass, :clover, :violets, :clover], garden.fred
  end

  def test_ginny
    skip
    assert_equal [:clover, :grass, :grass, :clover], garden.ginny
  end

  def test_harriet
    skip
    assert_equal [:violets, :radishes, :radishes, :violets], garden.harriet
  end

  def test_ileana
    skip
    assert_equal [:grass, :clover, :violets, :clover], garden.ileana
  end

  def test_joseph
    skip
    assert_equal [:violets, :clover, :violets, :grass], garden.joseph
  end

  def test_kincaid
    skip
    assert_equal [:grass, :clover, :clover, :grass], garden.kincaid
  end

  def test_larry
    skip
    assert_equal [:grass, :violets, :clover, :violets], garden.larry
  end
end

class DisorderedTest < Minitest::Test
  def setup
    skip
    diagram = "VCRRGVRG\nRVGCCGCV"
    students = %w(Samantha Patricia Xander Roger)
    @garden = Garden.new(diagram, students)
  end

  attr_reader :garden

  def test_patricia
    skip
    assert_equal [:violets, :clover, :radishes, :violets], garden.patricia
  end

  def test_roger
    skip
    assert_equal [:radishes, :radishes, :grass, :clover], garden.roger
  end

  def test_samantha
    skip
    assert_equal [:grass, :violets, :clover, :grass], garden.samantha
  end

  def test_xander
    skip
    assert_equal [:radishes, :grass, :clover, :violets], garden.xander
  end
end

class TwoGardensDifferentStudents < Minitest::Test
  def diagram
    "VCRRGVRG\nRVGCCGCV"
  end

  def garden_1
    @garden_1 ||= Garden.new(diagram, %w(Alice Bob Charlie Dan))
  end

  def garden_2
    @garden_2 ||= Garden.new(diagram, %w(Bob Charlie Dan Erin))
  end

  def test_bob_and_charlie_per_garden
    skip
    assert_equal [:radishes, :radishes, :grass, :clover], garden_1.bob
    assert_equal [:violets, :clover, :radishes, :violets], garden_2.bob
    assert_equal [:grass, :violets, :clover, :grass], garden_1.charlie
    assert_equal [:radishes, :radishes, :grass, :clover], garden_2.charlie
  end
end