mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-15 07:23:19 -04:00
White space fixes
This commit is contained in:
@@ -1,29 +1,29 @@
|
|||||||
= EdgeCase Ruby Koans
|
= EdgeCase Ruby Koans
|
||||||
|
|
||||||
The Ruby Koans walk you along the path to enlightenment in order to learn Ruby.
|
The Ruby Koans walk you along the path to enlightenment in order to learn Ruby.
|
||||||
The goal is to learn the Ruby language, syntax, structure, and some common
|
The goal is to learn the Ruby language, syntax, structure, and some common
|
||||||
functions and libraries. We also teach you culture. Testing is not just something we
|
functions and libraries. We also teach you culture. Testing is not just something we
|
||||||
pay lip service to, but something we live. It is essential in your quest to learn
|
pay lip service to, but something we live. It is essential in your quest to learn
|
||||||
and do great things in the language.
|
and do great things in the language.
|
||||||
|
|
||||||
== The Structure
|
== The Structure
|
||||||
|
|
||||||
The koans are broken out into areas by file, hashes are covered in about_hashes.rb,
|
The koans are broken out into areas by file, hashes are covered in about_hashes.rb,
|
||||||
modules are introduced in about_modules.rb, etc. They are presented in order in the
|
modules are introduced in about_modules.rb, etc. They are presented in order in the
|
||||||
path_to_enlightenment.rb file.
|
path_to_enlightenment.rb file.
|
||||||
|
|
||||||
Each koan builds up your knowledge of Ruby and builds upon itself. It will stop at
|
Each koan builds up your knowledge of Ruby and builds upon itself. It will stop at
|
||||||
the first place you need to correct.
|
the first place you need to correct.
|
||||||
|
|
||||||
Some koans simply need to have the correct answer substituted for an incorrect one.
|
Some koans simply need to have the correct answer substituted for an incorrect one.
|
||||||
Some, however, require you to supply your own answer. If you see the method +__+ (a
|
Some, however, require you to supply your own answer. If you see the method +__+ (a
|
||||||
double underscore) listed, it is a hint to you to supply your own code in order to
|
double underscore) listed, it is a hint to you to supply your own code in order to
|
||||||
make it work correctly.
|
make it work correctly.
|
||||||
|
|
||||||
== Installing Ruby
|
== Installing Ruby
|
||||||
|
|
||||||
If you do not have Ruby setup, please visit http://ruby-lang.org/en/downloads/ for
|
If you do not have Ruby setup, please visit http://ruby-lang.org/en/downloads/ for
|
||||||
operating specific instructions. In order to run this you need ruby and rake
|
operating specific instructions. In order to run this you need ruby and rake
|
||||||
installed. To check the installations simply type:
|
installed. To check the installations simply type:
|
||||||
|
|
||||||
*nix platforms from any terminal window:
|
*nix platforms from any terminal window:
|
||||||
@@ -33,11 +33,11 @@ installed. To check the installations simply type:
|
|||||||
|
|
||||||
Windows from the command prompt (cmd.exe)
|
Windows from the command prompt (cmd.exe)
|
||||||
|
|
||||||
c:\ruby --version
|
c:\ruby --version
|
||||||
c:\rake --version
|
c:\rake --version
|
||||||
|
|
||||||
Any response for Ruby with a version number greater than 1.8 is fine (should be
|
Any response for Ruby with a version number greater than 1.8 is fine (should be
|
||||||
around 1.8.6 or more). Any version of rake will do.
|
around 1.8.6 or more). Any version of rake will do.
|
||||||
|
|
||||||
== The Path To Enlightenment
|
== The Path To Enlightenment
|
||||||
|
|
||||||
@@ -48,18 +48,18 @@ recommended way to run them as we might build more functionality into this task)
|
|||||||
|
|
||||||
[ruby_koans] $ rake # runs the default target :walk_the_path
|
[ruby_koans] $ rake # runs the default target :walk_the_path
|
||||||
[ruby_koans] $ ruby path_to_enlightenment.rb # simply call the file directly
|
[ruby_koans] $ ruby path_to_enlightenment.rb # simply call the file directly
|
||||||
|
|
||||||
Windows is the same thing
|
Windows is the same thing
|
||||||
|
|
||||||
c:\ruby_koans\rake # runs the default target :walk_the_path
|
c:\ruby_koans\rake # runs the default target :walk_the_path
|
||||||
c:\ruby_koans\ruby path_to_enlightenment.rb # simply call the file directly
|
c:\ruby_koans\ruby path_to_enlightenment.rb # simply call the file directly
|
||||||
|
|
||||||
=== Red, Green, Refactor
|
=== Red, Green, Refactor
|
||||||
|
|
||||||
In test-driven development the mantra has always been, red, green, refactor. Write a
|
In test-driven development the mantra has always been, red, green, refactor. Write a
|
||||||
failing test and run it (red), make the test pass (green), then refactor it (that is
|
failing test and run it (red), make the test pass (green), then refactor it (that is
|
||||||
look at the code and see if you can make it any better. In this case you will need
|
look at the code and see if you can make it any better. In this case you will need
|
||||||
to run the koan and see it fail (red), make the test pass (green), then take a
|
to run the koan and see it fail (red), make the test pass (green), then take a
|
||||||
moment and reflect upon the test to see what it is teaching you and improve the
|
moment and reflect upon the test to see what it is teaching you and improve the
|
||||||
code to better communicate its intent (refactor).
|
code to better communicate its intent (refactor).
|
||||||
|
|
||||||
@@ -68,26 +68,26 @@ The very first time you run it you will see the following output:
|
|||||||
[ ruby_koans ] $ rake
|
[ ruby_koans ] $ rake
|
||||||
(in /Users/person/dev/ruby_koans)
|
(in /Users/person/dev/ruby_koans)
|
||||||
cd koans
|
cd koans
|
||||||
|
|
||||||
Thinking AboutAsserts
|
Thinking AboutAsserts
|
||||||
test_assert_truth has damaged your karma.
|
test_assert_truth has damaged your karma.
|
||||||
|
|
||||||
You have not yet reached enlightenment ...
|
You have not yet reached enlightenment ...
|
||||||
<false> is not true.
|
<false> is not true.
|
||||||
|
|
||||||
Please meditate on the following code:
|
Please meditate on the following code:
|
||||||
./about_asserts.rb:10:in `test_assert_truth'
|
./about_asserts.rb:10:in `test_assert_truth'
|
||||||
path_to_enlightenment.rb:27
|
path_to_enlightenment.rb:27
|
||||||
|
|
||||||
mountains are merely mountains
|
mountains are merely mountains
|
||||||
|
|
||||||
You have come to your first stage. If you notice it is telling you where to look for
|
You have come to your first stage. If you notice it is telling you where to look for
|
||||||
the first solution:
|
the first solution:
|
||||||
|
|
||||||
Please meditate on the following code:
|
Please meditate on the following code:
|
||||||
./about_asserts.rb:10:in `test_assert_truth'
|
./about_asserts.rb:10:in `test_assert_truth'
|
||||||
path_to_enlightenment.rb:27
|
path_to_enlightenment.rb:27
|
||||||
|
|
||||||
We then open up the about_asserts.rb file and look at the first test:
|
We then open up the about_asserts.rb file and look at the first test:
|
||||||
|
|
||||||
# We shall contemplate truth by testing reality, via asserts.
|
# We shall contemplate truth by testing reality, via asserts.
|
||||||
@@ -97,13 +97,13 @@ We then open up the about_asserts.rb file and look at the first test:
|
|||||||
|
|
||||||
We then change the +false+ to +true+ and run the test again. After you are
|
We then change the +false+ to +true+ and run the test again. After you are
|
||||||
done, think about what you are learning. In this case, ignore everything except
|
done, think about what you are learning. In this case, ignore everything except
|
||||||
the method name (+test_assert_truth+) and the parts inside the method (everything
|
the method name (+test_assert_truth+) and the parts inside the method (everything
|
||||||
before the +end+).
|
before the +end+).
|
||||||
|
|
||||||
In this case the goal is for you to see that if you pass a value to the +assert+
|
In this case the goal is for you to see that if you pass a value to the +assert+
|
||||||
method, it will either ensure it is +true+ and continue on, or fail if in fact
|
method, it will either ensure it is +true+ and continue on, or fail if in fact
|
||||||
the statement is +false+.
|
the statement is +false+.
|
||||||
|
|
||||||
== Inspiration
|
== Inspiration
|
||||||
|
|
||||||
A special thanks to Mike Clark and Ara Howard for inspiring this
|
A special thanks to Mike Clark and Ara Howard for inspiring this
|
||||||
|
|||||||
Reference in New Issue
Block a user