Skip to content

Commit 67d4147

Browse files
author
Pawel Lorek
committedJun 13, 2011
Another small step for human kind - but gigant leap on the path to enlightenment
1 parent 6cfdf83 commit 67d4147

4 files changed

+39
-31
lines changed
 

‎.path_progress

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0,1,5,6,6,6,6,7,8,9,10,11,11,11,12,13,14,15,16,17,17,18,18,18,19,18,19,18,20,21,22,23,24,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,42,46,47,47,46,51,54,55,56,57,59,60,60,62,62,63,64,67,70,70,71,71,71,73,74,75,75,78,79,80,80,81,83,83,85,87,88,91,92,92,92,94,95,95,97,98,99,101,102,103,104,105,107,107,107,110,110,110,110,111,110,110,110,111,112,113,114,117,118,119,121,121,123,126,127,128,128,128,131,132,136,137,140,144,147,147,147,147,147,148,148,148,149,152,144,144,144,144,144,144,152,144,152,152,152,152,154,154,156,158,160,161,161,161,162,166,167,169,171,171,171,171,172,172,161,172,172,173,175,175,176,176,176,177,176,176,176,176,176,177,178,176,178,184,176,176,184
1+
0,1,5,6,6,6,6,7,8,9,10,11,11,11,12,13,14,15,16,17,17,18,18,18,19,18,19,18,20,21,22,23,24,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,42,46,47,47,46,51,54,55,56,57,59,60,60,62,62,63,64,67,70,70,71,71,71,73,74,75,75,78,79,80,80,81,83,83,85,87,88,91,92,92,92,94,95,95,97,98,99,101,102,103,104,105,107,107,107,110,110,110,110,111,110,110,110,111,112,113,114,117,118,119,121,121,123,126,127,128,128,128,131,132,136,137,140,144,147,147,147,147,147,148,148,148,149,152,144,144,144,144,144,144,152,144,152,152,152,152,154,154,156,158,160,161,161,161,162,166,167,169,171,171,171,171,172,172,161,172,172,173,175,175,176,176,176,177,176,176,176,176,176,177,178,176,178,184,176,176,184,184,185,185,185,186,186,187,188,188,190,191,193,194,195,197,197,197,198,199,199,199,199,199,200,203,204,204,204,208

‎about_classes.rb

+23-23
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Dog
66

77
def test_instances_of_classes_can_be_created_with_new
88
fido = Dog.new
9-
assert_equal __, fido.class
9+
assert_equal Dog, fido.class
1010
end
1111

1212
# ------------------------------------------------------------------
@@ -19,21 +19,21 @@ def set_name(a_name)
1919

2020
def test_instance_variables_can_be_set_by_assigning_to_them
2121
fido = Dog2.new
22-
assert_equal __, fido.instance_variables
22+
assert_equal [], fido.instance_variables
2323

2424
fido.set_name("Fido")
25-
assert_equal __, fido.instance_variables
25+
assert_equal [:@name], fido.instance_variables
2626
end
2727

2828
def test_instance_variables_cannot_be_accessed_outside_the_class
2929
fido = Dog2.new
3030
fido.set_name("Fido")
3131

32-
assert_raise(___) do
32+
assert_raise(NoMethodError) do
3333
fido.name
3434
end
3535

36-
assert_raise(___) do
36+
assert_raise(SyntaxError) do
3737
eval "fido.@name"
3838
# NOTE: Using eval because the above line is a syntax error.
3939
end
@@ -43,15 +43,15 @@ def test_you_can_politely_ask_for_instance_variable_values
4343
fido = Dog2.new
4444
fido.set_name("Fido")
4545

46-
assert_equal __, fido.instance_variable_get("@name")
46+
assert_equal "Fido", fido.instance_variable_get("@name")
4747
end
4848

4949
def test_you_can_rip_the_value_out_using_instance_eval
5050
fido = Dog2.new
5151
fido.set_name("Fido")
5252

53-
assert_equal __, fido.instance_eval("@name") # string version
54-
assert_equal __, fido.instance_eval { @name } # block version
53+
assert_equal "Fido", fido.instance_eval("@name") # string version
54+
assert_equal "Fido", fido.instance_eval { @name } # block version
5555
end
5656

5757
# ------------------------------------------------------------------
@@ -69,7 +69,7 @@ def test_you_can_create_accessor_methods_to_return_instance_variables
6969
fido = Dog3.new
7070
fido.set_name("Fido")
7171

72-
assert_equal __, fido.name
72+
assert_equal "Fido", fido.name
7373
end
7474

7575
# ------------------------------------------------------------------
@@ -87,7 +87,7 @@ def test_attr_reader_will_automatically_define_an_accessor
8787
fido = Dog4.new
8888
fido.set_name("Fido")
8989

90-
assert_equal __, fido.name
90+
assert_equal "Fido", fido.name
9191
end
9292

9393
# ------------------------------------------------------------------
@@ -101,7 +101,7 @@ def test_attr_accessor_will_automatically_define_both_read_and_write_accessors
101101
fido = Dog5.new
102102

103103
fido.name = "Fido"
104-
assert_equal __, fido.name
104+
assert_equal "Fido", fido.name
105105
end
106106

107107
# ------------------------------------------------------------------
@@ -115,11 +115,11 @@ def initialize(initial_name)
115115

116116
def test_initialize_provides_initial_values_for_instance_variables
117117
fido = Dog6.new("Fido")
118-
assert_equal __, fido.name
118+
assert_equal "Fido", fido.name
119119
end
120120

121121
def test_args_to_new_must_match_initialize
122-
assert_raise(___) do
122+
assert_raise(ArgumentError) do
123123
Dog6.new
124124
end
125125
# THINK ABOUT IT:
@@ -130,7 +130,7 @@ def test_different_objects_have_difference_instance_variables
130130
fido = Dog6.new("Fido")
131131
rover = Dog6.new("Rover")
132132

133-
assert_equal __, rover.name != fido.name
133+
assert_equal true, rover.name != fido.name
134134
end
135135

136136
# ------------------------------------------------------------------
@@ -147,7 +147,7 @@ def get_self
147147
end
148148

149149
def to_s
150-
__
150+
@name
151151
end
152152

153153
def inspect
@@ -159,32 +159,32 @@ def test_inside_a_method_self_refers_to_the_containing_object
159159
fido = Dog7.new("Fido")
160160

161161
fidos_self = fido.get_self
162-
assert_equal __, fidos_self
162+
assert_equal fido, fidos_self
163163
end
164164

165165
def test_to_s_provides_a_string_version_of_the_object
166166
fido = Dog7.new("Fido")
167-
assert_equal __, fido.to_s
167+
assert_equal "Fido", fido.to_s
168168
end
169169

170170
def test_to_s_is_used_in_string_interpolation
171171
fido = Dog7.new("Fido")
172-
assert_equal __, "My dog is #{fido}"
172+
assert_equal "My dog is Fido", "My dog is #{fido}"
173173
end
174174

175175
def test_inspect_provides_a_more_complete_string_version
176176
fido = Dog7.new("Fido")
177-
assert_equal __, fido.inspect
177+
assert_equal "<Dog named 'Fido'>", fido.inspect
178178
end
179179

180180
def test_all_objects_support_to_s_and_inspect
181181
array = [1,2,3]
182182

183-
assert_equal __, array.to_s
184-
assert_equal __, array.inspect
183+
assert_equal "[1, 2, 3]", array.to_s
184+
assert_equal "[1, 2, 3]", array.inspect
185185

186-
assert_equal __, "STRING".to_s
187-
assert_equal __, "STRING".inspect
186+
assert_equal "STRING", "STRING".to_s
187+
assert_equal "\"STRING\"", "STRING".inspect
188188
end
189189

190190
end

‎about_dice_project.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
# Implement a DiceSet Class here:
44
#
5-
# class DiceSet
5+
class DiceSet
66
# code ...
7-
# end
7+
def roll(n)
8+
@values = []
9+
n.times{ |i| @values << (rand(6)+1) }
10+
end
11+
12+
def values
13+
@values
14+
end
15+
end
816

917
class AboutDiceProject < EdgeCase::Koan
1018
def test_can_create_a_dice_set

‎about_open_classes.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def bark
99

1010
def test_as_defined_dogs_do_bark
1111
fido = Dog.new
12-
assert_equal __, fido.bark
12+
assert_equal "WOOF", fido.bark
1313
end
1414

1515
# ------------------------------------------------------------------
@@ -23,8 +23,8 @@ def wag
2323

2424
def test_after_reopening_dogs_can_both_wag_and_bark
2525
fido = Dog.new
26-
assert_equal __, fido.wag
27-
assert_equal __, fido.bark
26+
assert_equal "HAPPY", fido.wag
27+
assert_equal "WOOF", fido.bark
2828
end
2929

3030
# ------------------------------------------------------------------
@@ -36,8 +36,8 @@ def even?
3636
end
3737

3838
def test_even_existing_built_in_classes_can_be_reopened
39-
assert_equal __, 1.even?
40-
assert_equal __, 2.even?
39+
assert_equal false, 1.even?
40+
assert_equal true, 2.even?
4141
end
4242

4343
# NOTE: To understand why we need the :: before Integer, you need to

0 commit comments

Comments
 (0)
Please sign in to comment.