Skip to content

Commit 5510c99

Browse files
committed
generated
1 parent 747f3f6 commit 5510c99

File tree

52 files changed

+2559
-810
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2559
-810
lines changed

00_hello/hello_spec.rb

+116
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,119 @@
1+
# # Hello!
2+
#
3+
# This lab teaches basic Ruby function syntax.
4+
#
5+
# ## Open a terminal in this directory
6+
#
7+
# cd 00_hello
8+
#
9+
# This directory is the starting point for this exercise. It contains a spec file and you'll be adding a ruby file to (eventually) make the specs pass.
10+
#
11+
# ## Run the test
12+
#
13+
# rake
14+
#
15+
# ## Watch it fail
16+
#
17+
# You should see an error. **Don't get scared!** Try to read it and figure out what the computer wants to tell you. Somewhere on the first line it should say something like
18+
#
19+
# no such file to load -- test-first-teaching/hello/hello (LoadError)
20+
#
21+
# That means that it is looking for a file called `hello.rb` and can't find it.
22+
#
23+
# ## Create hello.rb
24+
#
25+
# Open up `hello.rb` in a text editor. Save it. Run the test again.
26+
#
27+
# rake
28+
#
29+
# ## Watch it fail
30+
#
31+
# Now you should see an error like this:
32+
#
33+
# the hello function
34+
# says hello (FAILED - 1)
35+
#
36+
# Failures:
37+
#
38+
# 1) the hello function says hello
39+
# Failure/Error: hello.should == "Hello!"
40+
# NameError:
41+
# undefined local variable or method `hello' for #<RSpec::Core::ExampleGroup::Nested_1:0x000001009b8808>
42+
# # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
43+
#
44+
# ## Create the hello function
45+
#
46+
# Fix this by opening `hello.rb` and creating an empty function:
47+
#
48+
# def hello
49+
# end
50+
#
51+
# Save it. Run the test again.
52+
#
53+
# ## Watch it fail
54+
#
55+
# Now you should see an error like this:
56+
#
57+
# the hello function
58+
# says hello (FAILED - 1)
59+
#
60+
# Failures:
61+
#
62+
# 1) the hello function says hello
63+
# Failure/Error: hello().should == "Hello!"
64+
# expected: "Hello!"
65+
# got: nil (using ==)
66+
# # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
67+
#
68+
# This means that while it found the file, and it found the function, it's not returning anything! ("nil" is the Ruby way of saying "not anything".)
69+
#
70+
# ## Make it return something
71+
#
72+
# Inside the "hello" function, put a single line containing a string that is *not* "Hello!". (Here we are simulating you making an honest mistake, so we can see what the error message looks like.)
73+
#
74+
# def hello
75+
# "whuh?"
76+
# end
77+
#
78+
# Save it. Run the test again.
79+
#
80+
# ## Watch it fail
81+
#
82+
# Now you should see an error like this:
83+
#
84+
# 1) the hello function says hello
85+
# Failure/Error: hello().should == "Hello!"
86+
# expected: "Hello!"
87+
# got: "whuh?" (using ==)
88+
# # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
89+
#
90+
# Correct this by changing "whuh?" to "Hello!". Save it. Run the test again.
91+
#
92+
# ## Watch it pass!
93+
#
94+
# Hooray! Finally! It works!
95+
#
96+
# ## Give yourself a high five
97+
#
98+
# Also, sing a song and do a little dance.
99+
#
100+
# ## And then...
101+
#
102+
# Fix the next failure! `:-)`
103+
#
104+
# the hello function
105+
# says hello
106+
#
107+
# the greet function
108+
# says hello to someone (FAILED - 1)
109+
#
110+
# In order to get the next test to pass, your function will need to accept an *argument*.
111+
#
112+
# def greet(who)
113+
# "Hello, #{who}!"
114+
# end
115+
#
116+
# <!-- -->
1117
require "hello"
2118

3119
describe "the hello function" do

00_hello/index.html

+59-22
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
<html>
2-
<head>
3-
<title>Test-First Teaching: learn_ruby: hello</title>
4-
<link href="../assets/style.css" media="screen" rel="stylesheet" type="text/css" />
5-
</head>
6-
<body>
7-
<div class='header'>
8-
<h1><a href="http://testfirst.org">TestFirst.org</a></h1>
9-
<h2>the home of test-first teaching</h2>
10-
</div>
11-
<div class="nav"><h2><a href="../index.html">learn_ruby</a></h2><b>Labs:</b><ul><li>00 Hello</li><li><a href="../01_temperature/index.html">01 Temperature</a></li><li><a href="../02_calculator/index.html">02 Calculator</a></li><li><a href="../03_mega_calculator/index.html">03 Mega Calculator</a></li><li><a href="../04_simon_says/index.html">04 Simon Says</a></li><li><a href="../05_pig_latin/index.html">05 Pig Latin</a></li><li><a href="../06_silly_blocks/index.html">06 Silly Blocks</a></li><li><a href="../07_performance_monitor/index.html">07 Performance Monitor</a></li><li><a href="../08_hello_friend/index.html">08 Hello Friend</a></li><li><a href="../09_temperature_object/index.html">09 Temperature Object</a></li><li><a href="../10_book_titles/index.html">10 Book Titles</a></li><li><a href="../11_timer/index.html">11 Timer</a></li><li><a href="../12_dictionary/index.html">12 Dictionary</a></li><li><a href="../13_rpn_calculator/index.html">13 Rpn Calculator</a></li><li><a href="../14_xml_document/index.html">14 Xml Document</a></li><li><a href="../15_array_extensions/index.html">15 Array Extensions</a></li><li><a href="../16_in_words/index.html">16 In Words</a></li></ul></div>
12-
<div class="info"><h1>hello</h1><ul><li><a href="hello_spec.rb">hello_spec.rb</a></li></ul></div>
13-
<div class='content'>
14-
<h1>Hello!</h1>
2+
<head>
3+
<title>Test-First Teaching: learn_ruby: hello</title>
4+
<link href="../assets/style.css" media="screen" rel="stylesheet" type="text/css" />
5+
</head>
6+
<body>
7+
<div class="header">
8+
<h1><a href="http://testfirst.org">TestFirst.org</a></h1>
9+
<h2>the home of test-first teaching</h2>
10+
</div>
11+
<div class="nav">
12+
<h2><a href="../index.html">learn_ruby</a></h2>
13+
<b>Labs:</b>
14+
<ul>
15+
<li>00 Hello</li>
16+
<li><a href="../01_temperature/index.html">01 Temperature</a></li>
17+
<li><a href="../02_calculator/index.html">02 Calculator</a></li>
18+
<li><a href="../03_simon_says/index.html">03 Simon Says</a></li>
19+
<li><a href="../04_pig_latin/index.html">04 Pig Latin</a></li>
20+
<li><a href="../05_silly_blocks/index.html">05 Silly Blocks</a></li>
21+
<li><a href="../06_performance_monitor/index.html">06 Performance Monitor</a></li>
22+
<li><a href="../07_hello_friend/index.html">07 Hello Friend</a></li>
23+
<li><a href="../08_temperature_object/index.html">08 Temperature Object</a></li>
24+
<li><a href="../09_book_titles/index.html">09 Book Titles</a></li>
25+
<li><a href="../10_timer/index.html">10 Timer</a></li>
26+
<li><a href="../11_dictionary/index.html">11 Dictionary</a></li>
27+
<li><a href="../12_rpn_calculator/index.html">12 Rpn Calculator</a></li>
28+
<li><a href="../13_xml_document/index.html">13 Xml Document</a></li>
29+
<li><a href="../14_array_extensions/index.html">14 Array Extensions</a></li>
30+
<li><a href="../15_in_words/index.html">15 In Words</a></li>
31+
</ul>
32+
</div>
33+
<h1>hello</h1>
34+
<div class="content"><div class="rspec_file"> <div class="intro"><h1>Hello!</h1>
1535

1636
<p>This lab teaches basic Ruby function syntax.</p>
1737

@@ -22,7 +42,7 @@ <h2>Open a terminal in this directory</h2>
2242

2343
<p>This directory is the starting point for this exercise. It contains a spec file and you'll be adding a ruby file to (eventually) make the specs pass.</p>
2444

25-
<h2>Run the spec</h2>
45+
<h2>Run the test</h2>
2646

2747
<pre><code>rake
2848
</code></pre>
@@ -38,7 +58,7 @@ <h2>Watch it fail</h2>
3858

3959
<h2>Create hello.rb</h2>
4060

41-
<p>Open up <code>hello.rb</code> in a text editor. Save it. Run the spec again.</p>
61+
<p>Open up <code>hello.rb</code> in a text editor. Save it. Run the test again.</p>
4262

4363
<pre><code>rake
4464
</code></pre>
@@ -67,7 +87,7 @@ <h2>Create the hello function</h2>
6787
end
6888
</code></pre>
6989

70-
<p>Save it. Run the spec again.</p>
90+
<p>Save it. Run the test again.</p>
7191

7292
<h2>Watch it fail</h2>
7393

@@ -96,7 +116,7 @@ <h2>Make it return something</h2>
96116
end
97117
</code></pre>
98118

99-
<p>Save it. Run the spec again.</p>
119+
<p>Save it. Run the test again.</p>
100120

101121
<h2>Watch it fail</h2>
102122

@@ -109,7 +129,7 @@ <h2>Watch it fail</h2>
109129
# ./hello/hello_spec.rb:5:in `block (2 levels) in &lt;top (required)&gt;'
110130
</code></pre>
111131

112-
<p>Correct this by changing "whuh?" to "Hello!". Save it. Run the spec again.</p>
132+
<p>Correct this by changing "whuh?" to "Hello!". Save it. Run the test again.</p>
113133

114134
<h2>Watch it pass!</h2>
115135

@@ -139,9 +159,26 @@ <h2>And then...</h2>
139159

140160
<!-- -->
141161

162+
</div>
163+
<div class="tests">
164+
<h1>Tests</h1>
165+
<a class="raw_file" href="hello_spec.rb">hello_spec.rb</a>
166+
<pre>require &quot;hello&quot;
167+
168+
describe &quot;the hello function&quot; do
169+
it &quot;says hello&quot; do
170+
hello.should == &quot;Hello!&quot;
171+
end
172+
end
173+
174+
describe &quot;the greet function&quot; do
175+
it &quot;says hello to someone&quot; do
176+
greet(&quot;Bob&quot;).should == &quot;Hello, Bob!&quot;
177+
end
178+
end</pre>
142179
</div>
143-
<div class='footer'>
144-
<a href="http://testfirst.org">TestFirst.org</a>
145-
</div>
146-
</body>
180+
</div>
181+
</div>
182+
<div class="footer"><a href="http://testfirst.org">TestFirst.org</a></div>
183+
</body>
147184
</html>

01_temperature/index.html

+92-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
<html>
2-
<head>
3-
<title>Test-First Teaching: learn_ruby: temperature</title>
4-
<link href="../assets/style.css" media="screen" rel="stylesheet" type="text/css" />
5-
</head>
6-
<body>
7-
<div class='header'>
8-
<h1><a href="http://testfirst.org">TestFirst.org</a></h1>
9-
<h2>the home of test-first teaching</h2>
10-
</div>
11-
<div class="nav"><h2><a href="../index.html">learn_ruby</a></h2><b>Labs:</b><ul><li><a href="../00_hello/index.html">00 Hello</a></li><li>01 Temperature</li><li><a href="../02_calculator/index.html">02 Calculator</a></li><li><a href="../03_mega_calculator/index.html">03 Mega Calculator</a></li><li><a href="../04_simon_says/index.html">04 Simon Says</a></li><li><a href="../05_pig_latin/index.html">05 Pig Latin</a></li><li><a href="../06_silly_blocks/index.html">06 Silly Blocks</a></li><li><a href="../07_performance_monitor/index.html">07 Performance Monitor</a></li><li><a href="../08_hello_friend/index.html">08 Hello Friend</a></li><li><a href="../09_temperature_object/index.html">09 Temperature Object</a></li><li><a href="../10_book_titles/index.html">10 Book Titles</a></li><li><a href="../11_timer/index.html">11 Timer</a></li><li><a href="../12_dictionary/index.html">12 Dictionary</a></li><li><a href="../13_rpn_calculator/index.html">13 Rpn Calculator</a></li><li><a href="../14_xml_document/index.html">14 Xml Document</a></li><li><a href="../15_array_extensions/index.html">15 Array Extensions</a></li><li><a href="../16_in_words/index.html">16 In Words</a></li></ul></div>
12-
<div class="info"><h1>temperature</h1><ul><li><a href="temperature_spec.rb">temperature_spec.rb</a></li></ul></div>
13-
<div class='content'>
14-
<h1>Topics:</h1>
2+
<head>
3+
<title>Test-First Teaching: learn_ruby: temperature</title>
4+
<link href="../assets/style.css" media="screen" rel="stylesheet" type="text/css" />
5+
</head>
6+
<body>
7+
<div class="header">
8+
<h1><a href="http://testfirst.org">TestFirst.org</a></h1>
9+
<h2>the home of test-first teaching</h2>
10+
</div>
11+
<div class="nav">
12+
<h2><a href="../index.html">learn_ruby</a></h2>
13+
<b>Labs:</b>
14+
<ul>
15+
<li><a href="../00_hello/index.html">00 Hello</a></li>
16+
<li>01 Temperature</li>
17+
<li><a href="../02_calculator/index.html">02 Calculator</a></li>
18+
<li><a href="../03_simon_says/index.html">03 Simon Says</a></li>
19+
<li><a href="../04_pig_latin/index.html">04 Pig Latin</a></li>
20+
<li><a href="../05_silly_blocks/index.html">05 Silly Blocks</a></li>
21+
<li><a href="../06_performance_monitor/index.html">06 Performance Monitor</a></li>
22+
<li><a href="../07_hello_friend/index.html">07 Hello Friend</a></li>
23+
<li><a href="../08_temperature_object/index.html">08 Temperature Object</a></li>
24+
<li><a href="../09_book_titles/index.html">09 Book Titles</a></li>
25+
<li><a href="../10_timer/index.html">10 Timer</a></li>
26+
<li><a href="../11_dictionary/index.html">11 Dictionary</a></li>
27+
<li><a href="../12_rpn_calculator/index.html">12 Rpn Calculator</a></li>
28+
<li><a href="../13_xml_document/index.html">13 Xml Document</a></li>
29+
<li><a href="../14_array_extensions/index.html">14 Array Extensions</a></li>
30+
<li><a href="../15_in_words/index.html">15 In Words</a></li>
31+
</ul>
32+
</div>
33+
<h1>temperature</h1>
34+
<div class="content"><div class="rspec_file"> <div class="intro"><h1>Topics:</h1>
1535

1636
<ul>
1737
<li>functions</li>
@@ -30,9 +50,64 @@ <h1>Hints</h1>
3050
<p>In floating point math, there <strong>are</strong> fractions. So...</p>
3151

3252
<p> 1.0 / 2.0 => 0.5</p>
53+
</div>
54+
<div class="tests">
55+
<h1>Tests</h1>
56+
<a class="raw_file" href="temperature_spec.rb">temperature_spec.rb</a>
57+
<pre>
58+
require &quot;temperature&quot;
59+
60+
describe &quot;temperature conversion functions&quot; do
61+
62+
describe &quot;#ftoc&quot; do
63+
64+
it &quot;converts freezing temperature&quot; do
65+
ftoc(32).should == 0
66+
end
67+
68+
it &quot;converts boiling temperature&quot; do
69+
ftoc(212).should == 100
70+
end
71+
72+
it &quot;converts body temperature&quot; do
73+
ftoc(98.6).should == 37
74+
end
75+
76+
it &quot;converts arbitrary temperature&quot; do
77+
ftoc(68).should == 20
78+
end
79+
80+
end
81+
82+
describe &quot;#ctof&quot; do
83+
84+
it &quot;converts freezing temperature&quot; do
85+
ctof(0).should == 32
86+
end
87+
88+
it &quot;converts boiling temperature&quot; do
89+
ctof(100).should == 212
90+
end
91+
92+
it &quot;converts arbitrary temperature&quot; do
93+
ctof(20).should == 68
94+
end
95+
96+
it &quot;converts body temperature&quot; do
97+
ctof(37).should be_within(0.1).of(98.6)
98+
# Why do we need to use be_within?
99+
# See http://www.ruby-forum.com/topic/169330
100+
# and http://en.wikipedia.org/wiki/IEEE_754-2008
101+
# and http://en.wikipedia.org/wiki/Double_precision_floating-point_format
102+
# Also, try &quot;puts 0.5 - 0.4 - 0.1&quot; -- pretty crazy, right?
103+
end
104+
105+
end
106+
107+
end</pre>
33108
</div>
34-
<div class='footer'>
35-
<a href="http://testfirst.org">TestFirst.org</a>
36-
</div>
37-
</body>
109+
</div>
110+
</div>
111+
<div class="footer"><a href="http://testfirst.org">TestFirst.org</a></div>
112+
</body>
38113
</html>

01_temperature/temperature_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# # Topics:
2+
# * functions
3+
# * floating-point math
4+
#
5+
# # Hints
6+
#
7+
# Remember that one degree fahrenheit is 5/9 of one degree celsius, and that the freezing point of water is 0 degrees celsius but 32 degrees fahrenheit.
8+
#
9+
# In integer math, there **are no fractions**. So if you are using integer literals, you will be using integer math, which means, for example...
10+
#
11+
# 1 / 2 => 0
12+
#
13+
# In floating point math, there **are** fractions. So...
14+
#
15+
# 1.0 / 2.0 => 0.5
16+
#
17+
118
require "temperature"
219

320
describe "temperature conversion functions" do

0 commit comments

Comments
 (0)