diff --git a/00_hello/hello_spec.rb b/00_hello/hello_spec.rb index 97df6874d..b5c3526aa 100644 --- a/00_hello/hello_spec.rb +++ b/00_hello/hello_spec.rb @@ -1,5 +1,5 @@ -# You should be in the folder 00_hello on the command line, -# you should have already entered +# You should be in the folder 00_hello on the command line, +# you should have already entered # $ gem install rspec # and you should be running this problem's tests by entering # $ rake @@ -9,7 +9,7 @@ # it means get a file with the name "hello.rb" in the current directory. require "hello.rb" # To stop this error from being thrown we need to create the file: -# $ touch hello.rb +# $ touch hello.rb # Now if we run rake again, it will complain about "a undefined local variable or method `hello'" # Let's keep this in mind while we go through the next little bit of code. @@ -18,17 +18,17 @@ describe "the hello function" do # neither is #20, it "says hello" do - # but this is the important part. + # but this is the important part. # Line #24 is saying: if we call the method hello, what it returns should be equal to "Hello!" # If that's not the case, this is a failing test. - hello.should == "Hello!" + expect(hello).to eq("Hello!") # So in hello.rb let's define a method named hello, # and let's make it return "Hello!" # In hello.rb: - # + # # def hello - # return "Hello!" + # "Hello!" # end end end @@ -39,15 +39,15 @@ describe "the greet function" do it "says hello to someone" do - greet("Alice").should == "Hello, Alice!" + expect(greet("Alice")).to eq("Hello, Alice!") end it "says hello to someone else" do - greet("Bob").should == "Hello, Bob!" + expect(greet("Bob")).to eq("Hello, Bob!") end # These two tests are saying there should be a method named greet # that takes in a string, and returns that string inside of another string, a hello greeting. # Again, the method has to be defined in hello.rb # Try see if you can get this test to pass! -end \ No newline at end of file +end diff --git a/00_hello/index.html b/00_hello/index.html deleted file mode 100644 index bd5cc9084..000000000 --- a/00_hello/index.html +++ /dev/null @@ -1,185 +0,0 @@ - - - Test-First Teaching: learn_ruby: hello - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

hello

-

Hello!

- -

This lab teaches basic Ruby function syntax.

- -

Open a terminal in this directory

- -
cd 00_hello
-
- -

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.

- -

Run the test

- -
rake
-
- -

Watch it fail

- -

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

- -
no such file to load -- test-first-teaching/hello/hello (LoadError)
-
- -

That means that it is looking for a file called hello.rb and can't find it.

- -

Create hello.rb

- -

Open up hello.rb in a text editor. Save it. Run the test again.

- -
rake
-
- -

Watch it fail

- -

Now you should see an error like this:

- -
the hello function
-  says hello (FAILED - 1)
-
-Failures:
-
-  1) the hello function says hello
-     Failure/Error: hello.should == "Hello!"
-     NameError:
-       undefined local variable or method `hello' for #<RSpec::Core::ExampleGroup::Nested_1:0x000001009b8808>
-     # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
-
- -

Create the hello function

- -

Fix this by opening hello.rb and creating an empty function:

- -
def hello
-end
-
- -

Save it. Run the test again.

- -

Watch it fail

- -

Now you should see an error like this:

- -
the hello function
-  says hello (FAILED - 1)
-
-Failures:
-
-  1) the hello function says hello
-     Failure/Error: hello().should == "Hello!"
-       expected: "Hello!"
-            got: nil (using ==)
-     # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
-
- -

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".)

- -

Make it return something

- -

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.)

- -
def hello
-  "whuh?"
-end
-
- -

Save it. Run the test again.

- -

Watch it fail

- -

Now you should see an error like this:

- -
1) the hello function says hello
-   Failure/Error: hello().should == "Hello!"
-     expected: "Hello!"
-          got: "whuh?" (using ==)
-   # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
-
- -

Correct this by changing "whuh?" to "Hello!". Save it. Run the test again.

- -

Watch it pass!

- -

Hooray! Finally! It works!

- -

Give yourself a high five

- -

Also, sing a song and do a little dance.

- -

And then...

- -

Fix the next failure! :-)

- -
the hello function
-  says hello
-
-the greet function
-  says hello to someone (FAILED - 1)
-
- -

In order to get the next test to pass, your function will need to accept an argument.

- -
def greet(who)
-  "Hello, #{who}!"
-end
-
-
-
-

Tests

-hello_spec.rb -
require "hello"
-
-describe "the hello function" do
-  it "says hello" do
-    hello.should == "Hello!"
-  end
-end
-
-describe "the greet function" do
-  it "says hello to someone" do
-    greet("Alice").should == "Hello, Alice!"
-  end
-
-  it "says hello to someone else" do
-    greet("Bob").should == "Hello, Bob!"
-  end
-end
-
-
-
- - - diff --git a/01_temperature/index.html b/01_temperature/index.html deleted file mode 100644 index 3b6014315..000000000 --- a/01_temperature/index.html +++ /dev/null @@ -1,113 +0,0 @@ - - - Test-First Teaching: learn_ruby: temperature - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

temperature

-

Topics:

- -
    -
  • functions
  • -
  • floating-point math
  • -
- - -

Hints

- -

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.

- -

In integer math, there are no fractions. So if you are using integer literals, you will be using integer math, which means, for example...

- -

1 / 2 => 0

- -

In floating point math, there are fractions. So...

- -

1.0 / 2.0 => 0.5

-
-
-

Tests

-temperature_spec.rb -
-require "temperature"
-
-describe "temperature conversion functions" do
-
-  describe "#ftoc" do
-
-    it "converts freezing temperature" do
-      ftoc(32).should == 0
-    end
-
-    it "converts boiling temperature" do
-      ftoc(212).should == 100
-    end
-
-    it "converts body temperature" do
-      ftoc(98.6).should == 37
-    end
-
-    it "converts arbitrary temperature" do
-      ftoc(68).should == 20
-    end
-
-  end
-
-  describe "#ctof" do
-
-    it "converts freezing temperature" do
-      ctof(0).should == 32
-    end
-
-    it "converts boiling temperature" do
-      ctof(100).should == 212
-    end
-
-    it "converts arbitrary temperature" do
-      ctof(20).should == 68
-    end
-
-    it "converts body temperature" do
-      ctof(37).should be_within(0.1).of(98.6)
-      # Why do we need to use be_within?
-      # See http://www.ruby-forum.com/topic/169330
-      # and http://en.wikipedia.org/wiki/IEEE_754-2008
-      # and http://en.wikipedia.org/wiki/Double_precision_floating-point_format
-      # Also, try "puts 0.5 - 0.4 - 0.1" -- pretty crazy, right?
-    end
-
-  end
-
-end
-
-
-
- - - diff --git a/01_temperature/temperature_spec.rb b/01_temperature/temperature_spec.rb index 0088c5ff3..c181259cf 100644 --- a/01_temperature/temperature_spec.rb +++ b/01_temperature/temperature_spec.rb @@ -7,47 +7,46 @@ # Now maybe we can talk more about the lines we ignored last problem. # describe is a method that takes a sting and a do-end block. # The method is given to use by RSpec. -# The string should describe what is being tested in the do-end block. +# The string should describe what is being tested in the do-end block. describe "temperature conversion functions" do describe "#ftoc" do - # "it" is also a method that is given to us by RSpec, # that also takes a string and a do-end block. it "converts freezing temperature" do # Calling the method ftoc and passing in the integer 32 should return 0. - ftoc(32).should == 0 + expect(ftoc(32)).to eq(0) end - # The next three tests are similar, except different numbers are being passed in. + # The next three tests are similar, except different numbers are being passed in. it "converts boiling temperature" do - ftoc(212).should == 100 + expect(ftoc(212)).to eq(100) end it "converts body temperature" do - ftoc(98.6).should == 37 + expect(ftoc(98.6)).to eq(37) end it "converts arbitrary temperature" do - ftoc(68).should == 20 + expect(ftoc(68)).to eq(20) end end - # Now this set of tests describes a different method, - # not ftoc() anymore, but ctof(). + # Now this set of tests describes a different method, + # not ftoc() anymore, but ctof(). describe "#ctof" do it "converts freezing temperature" do - ctof(0).should == 32 + expect(ctof(0)).to eq(32) end it "converts boiling temperature" do - ctof(100).should == 212 + expect(ctof(100)).to eq(212) end it "converts arbitrary temperature" do - ctof(20).should == 68 + expect(ctof(20)).to eq(68) end end @@ -59,8 +58,8 @@ # but 1.0/2.0 equals 0.5 # It is important to know this difference to get these tests to pass. -# Also, you can use the following information to figure out what the equation -# is to convert between the two units, fahrenheit and celsius: -# +# Also, you can use the following information to figure out what the equation +# is to convert between the two units, fahrenheit and celsius: +# # 1. One degree fahrenheit is 5/9 of one degree celsius # 2. The freezing point of water is 0 degrees celsius but 32 degrees fahrenheit \ No newline at end of file diff --git a/02_calculator/calculator_spec.rb b/02_calculator/calculator_spec.rb index fecfea249..9e14859cc 100644 --- a/02_calculator/calculator_spec.rb +++ b/02_calculator/calculator_spec.rb @@ -1,4 +1,4 @@ -# In this problem we are going to make a calculator. +# In this problem we are going to make a calculator. # Remember to create the file! require "calculator.rb" @@ -7,15 +7,15 @@ describe "add" do it "adds 0 and 0" do - add(0,0).should == 0 + expect(add(0,0)).to eq(0) end it "adds 2 and 2" do - add(2,2).should == 4 + expect(add(2,2)).to eq(4) end it "adds positive numbers" do - add(2,6).should == 8 + expect(add(2,6)).to eq(8) end end @@ -23,7 +23,7 @@ describe "subtract" do it "subtracts numbers" do - subtract(10,4).should == 6 + expect(subtract(10,4)).to eq(6) end end @@ -32,19 +32,19 @@ describe "sum" do it "computes the sum of an empty array" do - sum([]).should == 0 + expect(sum([])).to eq(0) end it "computes the sum of an array of one number" do - sum([7]).should == 7 + expect(sum([7])).to eq(7) end it "computes the sum of an array of two numbers" do - sum([7,11]).should == 18 + expect(sum([7,11])).to eq(18) end it "computes the sum of an array of many numbers" do - sum([1,3,5,7,9]).should == 25 + expect(sum([1,3,5,7,9])).to eq(25) end end @@ -54,7 +54,7 @@ describe "#multiply" do - it "multiplies two numbers" do + it "multiplies two numbers" do end it "multiplies several numbers" do @@ -74,9 +74,9 @@ it "computes the factorial of 2" do end - it "computes the factorial of 5" do + it "computes the factorial of 5" do end - it "computes the factorial of 10" do + it "computes the factorial of 10" do end end diff --git a/02_calculator/index.html b/02_calculator/index.html deleted file mode 100644 index 037732e40..000000000 --- a/02_calculator/index.html +++ /dev/null @@ -1,146 +0,0 @@ - - - Test-First Teaching: learn_ruby: calculator - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

calculator

-

Topics

- -
    -
  • functions
  • -
  • math
  • -
  • arrays
  • -
  • iterating/looping
  • -
- - -

Calculator

- -

you will build a simple calculator script with the following methods:

- -

add takes two parameters and adds them

- -

subtract takes two parameters and subtracts the second from the first

- -

sum takes an array of parameters and adds them all together

- -

Warning

- -

You may not have enough knowledge yet to complete sum. You will probably -need to use loops (e.g. while) or iterators (e.g. each) to -get the tests to pass.

- -

Bonus

- -

There are also some bonus exercises for when you finish the regular ones. The bonus round will help teach you test-driven development, not simply test-guided learning.

- -

Your mission, should you choose to accept it, is to write tests for three new methods:

- -
    -
  • multiply which multiplies two numbers together
  • -
  • power which raises one number to the power of another number
  • -
  • [factorial](http://en.wikipedia.org/wiki/Factorial) (check Wikipedia if you forgot your high school math).
  • -
- -
-
-

Tests

-calculator_spec.rb -
-require "calculator"
-
-describe "add" do
-  it "adds 0 and 0" do
-    add(0,0).should == 0
-  end
-
-  it "adds 2 and 2" do
-    add(2,2).should == 4
-  end
-
-  it "adds positive numbers" do
-    add(2,6).should == 8
-  end
-end
-
-describe "subtract" do
-  it "subtracts numbers" do
-    subtract(10,4).should == 6
-  end
-end
-
-describe "sum" do
-  it "computes the sum of an empty array" do
-    sum([]).should == 0
-  end
-
-  it "computes the sum of an array of one number" do
-    sum([7]).should == 7
-  end
-
-  it "computes the sum of an array of two numbers" do
-    sum([7,11]).should == 18
-  end
-
-  it "computes the sum of an array of many numbers" do
-    sum([1,3,5,7,9]).should == 25
-  end
-end
-
-# Extra Credit Test-Driving Bonus:
-# once the above tests pass,
-# write tests and code for the following:
-
-describe "#multiply" do
-
-  it "multiplies two numbers"
-
-  it "multiplies several numbers"
-
-end
-
-describe "#power" do
-  it "raises one number to the power of another number"
-end
-
-# http://en.wikipedia.org/wiki/Factorial
-describe "#factorial" do
-  it "computes the factorial of 0"
-  it "computes the factorial of 1"
-  it "computes the factorial of 2"
-  it "computes the factorial of 5"
-  it "computes the factorial of 10"
-end
-
-
-
- - - diff --git a/03_simon_says/index.html b/03_simon_says/index.html deleted file mode 100644 index bfb8d6f29..000000000 --- a/03_simon_says/index.html +++ /dev/null @@ -1,141 +0,0 @@ - - - Test-First Teaching: learn_ruby: simon_says - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

simon_says

-

Simon Says

- -

Topics

- -
    -
  • functions
  • -
  • strings
  • -
  • default parameter values
  • -
- - -

Hints

- -

When you make the second repeat test pass, you might break the first

-
-
-

Tests

-simon_says_spec.rb -
-require "simon_says"
-
-describe "Simon says" do
-  describe "echo" do
-    it "should echo hello" do
-      echo("hello").should == "hello"
-    end
-
-    it "should echo bye" do
-      echo("bye").should == "bye"
-    end
-  end
-
-  describe "shout" do
-    it "should shout hello" do
-      shout("hello").should == "HELLO"
-    end
-
-    it "should shout multiple words" do
-      shout("hello world").should == "HELLO WORLD"
-    end
-  end
-
-  describe "repeat" do
-    it "should repeat" do
-      repeat("hello").should == "hello hello"
-    end
-
-    # Wait a second! How can you make the "repeat" method
-    # take one *or* two arguments?
-    #
-    # Hint: *default values*
-    it "should repeat a number of times" do
-      repeat("hello", 3).should == "hello hello hello"
-    end
-  end
-
-  describe "start_of_word" do
-    it "returns the first letter" do
-      start_of_word("hello", 1).should == "h"
-    end
-
-    it "returns the first two letters" do
-      start_of_word("Bob", 2).should == "Bo"
-    end
-
-    it "returns the first several letters" do
-      s = "abcdefg"
-      start_of_word(s, 1).should == "a"
-      start_of_word(s, 2).should == "ab"
-      start_of_word(s, 3).should == "abc"
-    end
-  end
-
-  describe "first_word" do
-    it "tells us the first word of 'Hello World' is 'Hello'" do
-      first_word("Hello World").should == "Hello"
-    end
-
-    it "tells us the first word of 'oh dear' is 'oh'" do
-      first_word("oh dear").should == "oh"
-    end
-  end
-
-  describe "titleize" do
-    it "capitalizes a word" do
-      titleize("jaws").should == "Jaws"
-    end
-
-    it "capitalizes every word (aka title case)" do
-      titleize("david copperfield").should == "David Copperfield"
-    end
-
-    it "doesn't capitalize 'little words' in a title" do
-      titleize("war and peace").should == "War and Peace"
-    end
-
-    it "does capitalize 'little words' at the start of a title" do
-      titleize("the bridge over the river kwai").should == "The Bridge over the River Kwai"
-    end
-  end
-
-end
-
-
-
- - - diff --git a/03_simon_says/simon_says_spec.rb b/03_simon_says/simon_says_spec.rb index 11f558093..b3155f438 100644 --- a/03_simon_says/simon_says_spec.rb +++ b/03_simon_says/simon_says_spec.rb @@ -1,6 +1,6 @@ require "simon_says" -# By now we should be getting better at reading tests. We should able to see +# By now we should be getting better at reading tests. We should able to see # what methods will need to be defined and what they need to return. describe "Simon says" do @@ -8,11 +8,11 @@ it "should echo hello" do # calling the method echo and passing in "hello" # should return "hello" - echo("hello").should == "hello" + expect(echo("hello")).to eq("hello") end it "should echo bye" do - echo("bye").should == "bye" + expect(echo("bye")).to eq("bye") end end @@ -20,17 +20,17 @@ it "should shout hello" do # calling the method shout and passing in "hello" # should return "HELLO" - shout("hello").should == "HELLO" + expect(shout("hello")).to eq("HELLO") end it "should shout multiple words" do - shout("hello world").should == "HELLO WORLD" + expect(shout("hello world")).to eq("HELLO WORLD") end end describe "repeat" do it "should repeat" do - repeat("hello").should == "hello hello" + expect(repeat("hello")).to eq("hello hello") end # Wait a second! How can you make the "repeat" method @@ -43,52 +43,52 @@ # The important part is num = 1. What happens is if a num isn't given, # then num will fallback on 1, i.e. it has a default value of 1. it "should repeat a number of times" do - repeat("hello", 3).should == "hello hello hello" + expect(repeat("hello", 3)).to eq("hello hello hello") end end describe "start_of_word" do it "returns the first letter" do - start_of_word("hello", 1).should == "h" + expect(start_of_word("hello", 1)).to eq("h") end it "returns the first two letters" do - start_of_word("Bob", 2).should == "Bo" + expect(start_of_word("Bob", 2)).to eq("Bo") end it "returns the first several letters" do s = "abcdefg" - start_of_word(s, 1).should == "a" - start_of_word(s, 2).should == "ab" - start_of_word(s, 3).should == "abc" + expect(start_of_word(s, 1)).to eq("a") + expect(start_of_word(s, 2)).to eq("ab") + expect(start_of_word(s, 3)).to eq("abc") end end describe "first_word" do it "tells us the first word of 'Hello World' is 'Hello'" do - first_word("Hello World").should == "Hello" + expect(first_word("Hello World")).to eq("Hello") end it "tells us the first word of 'oh dear' is 'oh'" do - first_word("oh dear").should == "oh" + expect(first_word("oh dear")).to eq("oh") end end describe "titleize" do it "capitalizes a word" do - titleize("jaws").should == "Jaws" + expect(titleize("jaws")).to eq("Jaws") end it "capitalizes every word (aka title case)" do - titleize("david copperfield").should == "David Copperfield" + expect(titleize("david copperfield")).to eq("David Copperfield") end it "doesn't capitalize 'little words' in a title" do - titleize("war and peace").should == "War and Peace" + expect(titleize("war and peace")).to eq("War and Peace") end it "does capitalize 'little words' at the start of a title" do - titleize("the bridge over the river kwai").should == "The Bridge over the River Kwai" + expect(titleize("the bridge over the river kwai")).to eq("The Bridge over the River Kwai") end end diff --git a/04_pig_latin/index.html b/04_pig_latin/index.html deleted file mode 100644 index da46cb79d..000000000 --- a/04_pig_latin/index.html +++ /dev/null @@ -1,116 +0,0 @@ - - - Test-First Teaching: learn_ruby: pig_latin - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

pig_latin

-

Topics

- -
    -
  • modules
  • -
  • strings
  • -
- - -

Pig Latin

- -

Pig Latin is a made-up children's language that's intended to be confusing. It obeys a few simple rules (below) but when it's spoken quickly it's really difficult for non-children (and non-native speakers) to understand.

- -

Rule 1: If a word begins with a vowel sound, add an "ay" sound to the end of the word.

- -

Rule 2: If a word begins with a consonant sound, move it to the end of the word, and then add an "ay" sound to the end of the word.

- -

(There are a few more rules for edge cases, and there are regional variants too, but that should be enough to understand the tests.)

- -

See http://en.wikipedia.org/wiki/Pig_latin for more details.

-
-
-

Tests

-pig_latin_spec.rb -
-require "pig_latin"
-
-describe "#translate" do
-
-  it "translates a word beginning with a vowel" do
-    s = translate("apple")
-    s.should == "appleay"
-  end
-
-  it "translates a word beginning with a consonant" do
-    s = translate("banana")
-    s.should == "ananabay"
-  end
-
-  it "translates a word beginning with two consonants" do
-    s = translate("cherry")
-    s.should == "errychay"
-  end
-
-  it "translates two words" do
-    s = translate("eat pie")
-    s.should == "eatay iepay"
-  end
-
-  it "translates a word beginning with three consonants" do
-    translate("three").should == "eethray"
-  end
-
-  it "counts 'sch' as a single phoneme" do
-    s = translate("school")
-    s.should == "oolschay"
-  end
-
-  it "counts 'qu' as a single phoneme" do
-    s = translate("quiet")
-    s.should == "ietquay"
-  end
-
-  it "counts 'qu' as a consonant even when it's preceded by a consonant" do
-    s = translate("square")
-    s.should == "aresquay"
-  end
-
-  it "translates many words" do
-    s = translate("the quick brown fox")
-    s.should == "ethay ickquay ownbray oxfay"
-  end
-
-  # Test-driving bonus:
-  # * write a test asserting that capitalized words are still capitalized (but with a different initial capital letter, of course)
-  # * retain the punctuation from the original phrase
-
-end
-
-
-
- - - diff --git a/04_pig_latin/pig_latin_spec.rb b/04_pig_latin/pig_latin_spec.rb index 1a8509ddc..73b4e08aa 100644 --- a/04_pig_latin/pig_latin_spec.rb +++ b/04_pig_latin/pig_latin_spec.rb @@ -10,46 +10,46 @@ it "translates a word beginning with a vowel" do s = translate("apple") - s.should == "appleay" + expect(s).to eq("appleay") end it "translates a word beginning with a consonant" do s = translate("banana") - s.should == "ananabay" + expect(s).to eq("ananabay") end it "translates a word beginning with two consonants" do s = translate("cherry") - s.should == "errychay" + expect(s).to eq("errychay") end # it "translates two words" do # s = translate("eat pie") - # s.should == "eatay iepay" + # expect(s).to eq("eatay iepay") # end # it "translates a word beginning with three consonants" do - # translate("three").should == "eethray" + # expect(translate("three")).to eq("eethray") # end # it "counts 'sch' as a single phoneme" do # s = translate("school") - # s.should == "oolschay" + # expect(s).to eq("oolschay") # end # it "counts 'qu' as a single phoneme" do # s = translate("quiet") - # s.should == "ietquay" + # expect(s).to eq("ietquay") # end # it "counts 'qu' as a consonant even when it's preceded by a consonant" do # s = translate("square") - # s.should == "aresquay" + # expect(s).to eq("aresquay") # end # it "translates many words" do # s = translate("the quick brown fox") - # s.should == "ethay ickquay ownbray oxfay" + # expect(s).to eq("ethay ickquay ownbray oxfay") # end # Extra challenges: diff --git a/05_silly_blocks/index.html b/05_silly_blocks/index.html deleted file mode 100644 index e13df82de..000000000 --- a/05_silly_blocks/index.html +++ /dev/null @@ -1,115 +0,0 @@ - - - Test-First Teaching: learn_ruby: silly_blocks - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

silly_blocks

-

Topics

- -
    -
  • blocks
  • -
  • closures
  • -
  • yield
  • -
  • loops
  • -
- -
-
-

Tests

-silly_blocks_spec.rb -
-require "silly_blocks"
-
-describe "some silly block functions" do
-
-  describe "reverser" do
-    it "reverses the string returned by the default block" do
-      result = reverser do
-        "hello"
-      end
-      result.should == "olleh"
-    end
-
-    it "reverses each word in the string returned by the default block" do
-      result = reverser do
-        "hello dolly"
-      end
-      result.should == "olleh yllod"
-    end
-  end
-
-  describe "adder" do
-    it "adds one to the value returned by the default block" do
-      adder do
-        5
-      end.should == 6
-    end
-
-    it "adds 3 to the value returned by the default block" do
-      adder(3) do
-        5
-      end.should == 8
-    end
-  end
-
-  describe "repeater" do
-    it "executes the default block" do
-      block_was_executed = false
-      repeater do
-        block_was_executed = true
-      end
-      block_was_executed.should == true
-    end
-
-    it "executes the default block 3 times" do
-      n = 0
-      repeater(3) do
-        n += 1
-      end
-      n.should == 3
-    end
-
-    it "executes the default block 10 times" do
-      n = 0
-      repeater(10) do
-        n += 1
-      end
-      n.should == 10
-    end
-
-  end
-
-end
-
-
-
- - - diff --git a/05_silly_blocks/silly_blocks_spec.rb b/05_silly_blocks/silly_blocks_spec.rb index 191beb8a1..2d713bc7d 100644 --- a/05_silly_blocks/silly_blocks_spec.rb +++ b/05_silly_blocks/silly_blocks_spec.rb @@ -7,14 +7,16 @@ result = reverser do "hello" end - result.should == "olleh" + + expect(result).to eq("olleh") + # You might be tempted to ask yourself what the hell is happening here. # Well no worries! Superman is here to the rescue! # (Heh, you probably don't even know whose written these comments.) - # + # # Let's look at this snippet of code in particular: - # - # reverser do + # + # reverser do # "hello" # end # @@ -22,36 +24,36 @@ # except the string is not being passed in as a parameter. It's being passed in as a do-end block. # The way this method can get that do-end block is through yield. # - # def example - # string = yield # yield is equal to... + # def example + # string = yield # yield is equal to... # string.upcase # end - # - # example do + # + # example do # "My name is Will Richman." # ...this line # end - # + # # So to get this test to pass the reverser method would look like: - # + # # def reverser # yield.reverse # end end it "reverses each word in the string returned by the default block" do - # Now edit the reverser method above to get this test to pass + # Now edit the reverser method above to get this test to pass result = reverser do "hello dolly" end - result.should == "olleh yllod" + expect(result).to eq("olleh yllod") end end describe "adder" do it "adds one to the value returned by the default block" do - adder do + expect(adder do 5 - end.should == 6 + end).to eq(6) # def adder # num = yield # # what do you want do you with num? @@ -59,9 +61,9 @@ end it "adds 3 to the value returned by the default block" do - adder(3) do + expect(adder(3) do 5 - end.should == 8 + end).to eq(8) end end @@ -71,7 +73,7 @@ repeater do n += 3 end - n.should == 5 + expect(n).to eq(5) end it "executes the default block 3 times" do @@ -79,7 +81,7 @@ repeater(3) do n += 1 end - n.should == 3 + expect(n).to eq(3) end it "executes the default block 10 times" do @@ -87,7 +89,7 @@ repeater(10) do n += 1 end - n.should == 10 + expect(n).to eq(10) end end diff --git a/06_hello_friend/hello_friend_spec.rb b/06_hello_friend/hello_friend_spec.rb index 0fb07b587..b408b9335 100644 --- a/06_hello_friend/hello_friend_spec.rb +++ b/06_hello_friend/hello_friend_spec.rb @@ -4,7 +4,7 @@ it "says hello to someone" do friend = Friend.new - friend.greet("Bob").should == "Hello Bob!" + expect(friend.greet("Bob")).to eq("Hello Bob!") end it "says hello to no one" do @@ -16,6 +16,6 @@ # # What should ? be equal to? friend = Friend.new - friend.greet.should == "Hello !" + expect(friend.greet).to eq("Hello !") end end diff --git a/06_hello_friend/index.html b/06_hello_friend/index.html deleted file mode 100644 index 865ca858f..000000000 --- a/06_hello_friend/index.html +++ /dev/null @@ -1,151 +0,0 @@ - - - Test-First Teaching: learn_ruby: hello_friend - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

hello_friend

-

Hello, friend!

- -

This lab teaches basic Ruby Object syntax.

- -

Watch it fail

- -

Your first real failure should be something like this:

- -
./friend_spec.rb:3: uninitialized constant Friend (NameError)
-
- -

Fix this by opening friend.rb and creating an empty class:

- -
class Friend
-end
-
- -

Save it. Run the test again.

- -

Watch it fail again

- -

Now you should see an error like this:

- -
NoMethodError in 'Friend says hello'
-undefined method `greeting' for #<Friend:0x1180f3c>
-./friend_spec.rb:5:
-
- -

This means that while it found the file, and it found the class, it couldn't find the method named "greeting".

- -

Define the "greeting" method

- -

In friend.rb, add the following inside the class (before the "end").

- -
def greeting
-end
-
- -

Save it. Run the test again.

- -

Watch it fail some more

- -

Now you should see an error like this:

- -
'Friend says hello' FAILED
-expected: "Hello!",
-     got: nil (using ==)
-./friend_spec.rb:5:
-
- -

This means that there is a method, but it's not returning anything! ("nil" is the Ruby way of saying "not anything".)

- -

Make it return something

- -

Inside the "greeting" method, 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.)

- -
def greeting
-  "whuh?"
-end
-
- -

Save it. Run the test again.

- -

Watch it fail yet again

- -

Now you should see an error like this:

- -
'Friend says hello' FAILED
-expected: "Hello!",
-     got: "whuh?" (using ==)
-./friend_spec.rb:5:
-
- -

Correct this by changing "whuh?" to "Hello!". Save it. Run the test again.

- -

Watch it pass!

- -

Hooray! Finally! It works!

- -

Give yourself a high five

- -

Also, sing a song and do a little dance.

- -

And then...

- -

Fix the next failure! :-)

- -

Hint 1: in order to get the next test to pass, you will need to pass a parameter:

- -
def greeting(who)
-
- -

Hint 2: once you do that, the first test might start failing again. To fix both at the same time, you need to provide a default value for that parameter:

- -
def greeting(who = nil)
-
-
-
-

Tests

-hello_friend_spec.rb -
-require "friend"
-
-describe Friend do
-  it "says hello" do
-    Friend.new.greeting.should == "Hello!"
-  end
-
-  it "says hello to someone" do
-    Friend.new.greeting("Bob").should == "Hello, Bob!"
-  end
-end
-
-
-
- - - diff --git a/07_book_titles/book_titles_spec.rb b/07_book_titles/book_titles_spec.rb index da6792046..c4b833dcc 100644 --- a/07_book_titles/book_titles_spec.rb +++ b/07_book_titles/book_titles_spec.rb @@ -12,12 +12,12 @@ it 'should capitalize the first letter' do # @book is a variable that was defined in the before do-end block. @book.title = "inferno" - @book.title.should == "Inferno" + expect(@book.title).to eq("Inferno") # Another way of saying these two lines is after we set the title of the book, when we get its title - # it should be capitalized properly. + # it should be capitalized properly. # We set the title of the book with @book.title = "inferno" # and we get the title of the book wtih @book.title - # + # # To be able to do @book.title = "inferno", # when we define the method title it has to look like this: # @@ -37,47 +37,47 @@ it 'should capitalize every word' do @book.title = "stuart little" - @book.title.should == "Stuart Little" + expect(@book.title).to eq("Stuart Little") end describe 'should capitalize every word except...' do describe 'articles' do specify 'the' do @book.title = "alexander the great" - @book.title.should == "Alexander the Great" + expect(@book.title).to eq("Alexander the Great") end specify 'a' do @book.title = "to kill a mockingbird" - @book.title.should == "To Kill a Mockingbird" + expect(@book.title).to eq("To Kill a Mockingbird") end specify 'an' do @book.title = "to eat an apple a day" - @book.title.should == "To Eat an Apple a Day" + expect(@book.title).to eq("To Eat an Apple a Day") end end specify 'conjunctions' do @book.title = "war and peace" - @book.title.should == "War and Peace" + expect(@book.title).to eq("War and Peace") end specify 'prepositions' do @book.title = "love in the time of cholera" - @book.title.should == "Love in the Time of Cholera" + expect(@book.title).to eq("Love in the Time of Cholera") end end describe 'should always capitalize...' do specify 'I' do @book.title = "what i wish i knew when i was 20" - @book.title.should == "What I Wish I Knew When I Was 20" + expect(@book.title).to eq("What I Wish I Knew When I Was 20") end specify 'the first word' do @book.title = "the man in the iron mask" - @book.title.should == "The Man in the Iron Mask" + expect(@book.title).to eq("The Man in the Iron Mask") end end end diff --git a/07_book_titles/index.html b/07_book_titles/index.html deleted file mode 100644 index 50dfe0ddd..000000000 --- a/07_book_titles/index.html +++ /dev/null @@ -1,120 +0,0 @@ - - - Test-First Teaching: learn_ruby: book_titles - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

book_titles

-

Book Titles

- -

Topics

- -
    -
  • classes and objects
  • -
  • instance variables
  • -
  • setter methods
  • -
  • strings
  • -
- - -

Notes

- -

Book Titles in English obey some strange capitalization rules. For example, "and" is lowercase in "War and Peace". This test attempts to make sense of some of those rules.

-
-
-

Tests

-book_titles_spec.rb -
-require 'book'
-
-describe Book do
-
-  before do
-    @book = Book.new
-  end
-
-  describe 'title' do
-    it 'should capitalize the first letter' do
-      @book.title = "inferno"
-      @book.title.should == "Inferno"
-    end
-
-    it 'should capitalize every word' do
-      @book.title = "stuart little"
-      @book.title.should == "Stuart Little"
-    end
-
-    describe 'should capitalize every word except...' do
-      describe 'articles' do
-        specify 'the' do
-          @book.title = "alexander the great"
-          @book.title.should == "Alexander the Great"
-        end
-
-        specify 'a' do
-          @book.title = "to kill a mockingbird"
-          @book.title.should == "To Kill a Mockingbird"
-        end
-
-        specify 'an' do
-          @book.title = "to eat an apple a day"
-          @book.title.should == "To Eat an Apple a Day"
-        end
-      end
-
-      specify 'conjunctions' do
-        @book.title = "war and peace"
-        @book.title.should == "War and Peace"
-      end
-
-      specify 'prepositions' do
-        @book.title = "love in the time of cholera"
-        @book.title.should == "Love in the Time of Cholera"
-      end
-    end
-
-    describe 'should always capitalize...' do
-      specify 'I' do
-        @book.title = "what i wish i knew when i was 20"
-        @book.title.should == "What I Wish I Knew When I Was 20"
-      end
-
-      specify 'the first word' do
-        @book.title = "the man in the iron mask"
-        @book.title.should == "The Man in the Iron Mask"
-      end
-    end
-  end
-end
-
-
-
- - - diff --git a/08_book_titles/index.html b/08_book_titles/index.html deleted file mode 100644 index f1ea5a720..000000000 --- a/08_book_titles/index.html +++ /dev/null @@ -1,106 +0,0 @@ - - - Test-First Teaching: learn_ruby: timer - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

timer

-

Topics

- -
    -
  • classes
  • -
  • instance variables
  • -
  • string formats
  • -
  • modular arithmetic
  • -
- - -

Timer

-
-
-

Tests

-timer_spec.rb -
-require 'timer'
-
-describe "Timer" do
-  before(:each) do
-    @timer = Timer.new
-  end
-
-  it "should initialize to 0 seconds" do
-    @timer.seconds.should == 0
-  end
-
-  describe 'time_string' do
-    it "should display 0 seconds as 00:00:00" do
-      @timer.seconds = 0
-      @timer.time_string.should == "00:00:00"
-    end
-
-    it "should display 12 seconds as 00:00:12" do
-      @timer.seconds = 12
-      @timer.time_string.should == "00:00:12"
-    end
-
-    it "should display 66 seconds as 00:01:06" do
-      @timer.seconds = 66
-      @timer.time_string.should == "00:01:06"
-    end
-
-    it "should display 4000 seconds as 01:06:40" do
-      @timer.seconds = 4000
-      @timer.time_string.should == "01:06:40"
-    end
-  end
-
-
-  # One way to implement the Timer is with a helper method.
-  # Uncomment these specs if you want to test-drive that
-  # method, then call that method from inside of time_string.
-  #
-  # describe 'padded' do
-  #   it 'pads zero' do
-  #     @timer.padded(0).should == '00'
-  #   end
-  #   it 'pads one' do
-  #     @timer.padded(1).should == '01'
-  #   end
-  #   it "doesn't pad a two-digit number" do
-  #     @timer.padded(12).should == '12'
-  #   end
-  # end
-
-end
-
-
-
- - - diff --git a/08_book_titles/timer_spec.rb b/08_timer/timer_spec.rb similarity index 74% rename from 08_book_titles/timer_spec.rb rename to 08_timer/timer_spec.rb index b09912edd..c9b14f5bc 100644 --- a/08_book_titles/timer_spec.rb +++ b/08_timer/timer_spec.rb @@ -1,5 +1,5 @@ # Timer formats a given # of seconds -# into something you see on a stopwatch, i.e. 00:00:00 or 00:10:22 +# into something you see on a stopwatch, i.e. 00:00:00 or 00:10:22 require 'timer' @@ -12,28 +12,28 @@ end it "should initialize to 0 seconds" do - @timer.seconds.should == 0 + expect(@timer.seconds).to eq 0 end describe 'time_string' do it "should display 0 seconds as 00:00:00" do @timer.seconds = 0 - @timer.time_string.should == "00:00:00" + expect(@timer.time_string).to eq("00:00:00") end it "should display 12 seconds as 00:00:12" do @timer.seconds = 12 - @timer.time_string.should == "00:00:12" + expect(@timer.time_string).to eq("00:00:12") end it "should display 66 seconds as 00:01:06" do @timer.seconds = 66 - @timer.time_string.should == "00:01:06" + expect(@timer.time_string).to eq("00:01:06") end it "should display 4000 seconds as 01:06:40" do @timer.seconds = 4000 - @timer.time_string.should == "01:06:40" + expect(@timer.time_string).to eq("01:06:40") end end @@ -44,13 +44,13 @@ # # describe 'padded' do # it 'pads zero' do - # @timer.padded(0).should == '00' + # expect(@timer.padded(0)).to eq('00') # end # it 'pads one' do - # @timer.padded(1).should == '01' + # expect(@timer.padded(1)).to eq('01') # end # it "doesn't pad a two-digit number" do - # @timer.padded(12).should == '12' + # expect(@timer.padded(12)).to eq('12') # end # end diff --git a/09_array_extensions/array_extensions_spec.rb b/09_array_extensions/array_extensions_spec.rb index 65e3f1836..dbb111ec3 100755 --- a/09_array_extensions/array_extensions_spec.rb +++ b/09_array_extensions/array_extensions_spec.rb @@ -4,11 +4,11 @@ describe "#sum" do # it "has a #sum method" do - # [].should respond_to(:sum) - # Array.should respond_to(:sum) + # [].to respond_to(:sum) + # Array.to respond_to(:sum) # [] and Array are synonymous - # - # Whoa! Hold on! We're expected to add a method + # + # Whoa! Hold on! We're expected to add a method # to a class that already exists inside of Ruby? # Well, yes. And the way you can do that is quite easy: # @@ -22,21 +22,21 @@ # end it "should be 0 for an empty array" do - [].sum.should == 0 + expect([].sum).to eq(0) end it "should add all of the elements" do - [1,2,4].sum.should == 7 + expect([1,2,4]).sum.to eq(7) end end describe '#square' do it "does nothing to an empty array" do - [].square.should == [] + expect([].square).to eq([]) end it "returns a new array containing the squares of each element" do - [1,2,3].square.should == [1,4,9] + expect([1,2,3]).square.to eq([1,4,9]) end end @@ -44,7 +44,7 @@ it "squares each element of the original array" do array = [1,2,3] array.square! - array.should == [1,4,9] + expect(array).to eq([1,4,9]) end end diff --git a/09_array_extensions/index.html b/09_array_extensions/index.html deleted file mode 100644 index 28005d4ca..000000000 --- a/09_array_extensions/index.html +++ /dev/null @@ -1,90 +0,0 @@ - - - Test-First Teaching: learn_ruby: array_extensions - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

array_extensions

-

Array Extension

- -

Topics

- -
    -
  • objects, methods, classes
  • -
  • reopening classes
  • -
- -
-
-

Tests

-array_extensions_spec.rb -
-require "array_extensions" # we don't call it "array.rb" since that would be confusing
-
-describe Array do
-
-  describe "#sum" do
-    it "has a #sum method" do
-      [].should respond_to(:sum)
-    end
-
-    it "should be 0 for an empty array" do
-      [].sum.should == 0
-    end
-
-    it "should add all of the elements" do
-      [1,2,4].sum.should == 7
-    end
-  end
-
-  describe '#square' do
-    it "does nothing to an empty array" do
-      [].square.should == []
-    end
-
-    it "returns a new array containing the squares of each element" do
-      [1,2,3].square.should == [1,4,9]
-    end
-  end
-
-  describe '#square!' do
-    it "squares each element of the original array" do
-      array = [1,2,3]
-      array.square!
-      array.should == [1,4,9]
-    end
-  end
-
-end
-
-
-
- - - diff --git a/10_temperature_object/index.html b/10_temperature_object/index.html deleted file mode 100644 index a86e7b851..000000000 --- a/10_temperature_object/index.html +++ /dev/null @@ -1,172 +0,0 @@ - - - Test-First Teaching: learn_ruby: temperature_object - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

temperature_object

-

Topics:

- -
    -
  • floating-point math
  • -
  • objects
  • -
  • constructors
  • -
  • class methods
  • -
  • factory methods
  • -
  • options hashes
  • -
- - -

Hints

- -

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.

- -

Remember to define the from_celsius factory method as a class method, not an instance method.

- -

The temperature object's constructor should accept an options hash which contains either a :celcius entry or a :fahrenheit entry.

-
-
-

Tests

-temperature_object_spec.rb -
-require "temperature"
-
-describe Temperature do
-
-  describe "can be constructed with an options hash" do
-    describe "in degrees fahrenheit" do
-      it "at 50 degrees" do
-        Temperature.new(:f => 50).in_fahrenheit.should == 50
-      end
-
-      describe "and correctly convert to celsius" do
-        it "at freezing" do
-          Temperature.new(:f => 32).in_celsius.should == 0
-        end
-
-        it "at boiling" do
-          Temperature.new(:f => 212).in_celsius.should == 100
-        end
-
-        it "at body temperature" do
-          Temperature.new(:f => 98.6).in_celsius.should == 37
-        end
-
-        it "at an arbitrary temperature" do
-          Temperature.new(:f => 68).in_celsius.should == 20
-        end
-      end
-    end
-
-    describe "in degrees celsius" do
-      it "at 50 degrees" do
-        Temperature.new(:c => 50).in_celsius.should == 50
-      end
-
-      describe "and correctly convert to fahrenheit" do
-        it "at freezing" do
-          Temperature.new(:c => 0).in_fahrenheit.should == 32
-        end
-
-        it "at boiling" do
-          Temperature.new(:c => 100).in_fahrenheit.should == 212
-        end
-
-        it "at body temperature" do
-          Temperature.new(:c => 37).in_fahrenheit.should be_within(0.1).of(98.6)
-          # Why do we need to use be_within here?
-          # See http://www.ruby-forum.com/topic/169330
-          # and http://groups.google.com/group/rspec/browse_thread/thread/f3ebbe3c313202bb
-          # Also, try "puts 0.5 - 0.4 - 0.1" -- pretty crazy, right?
-        end
-      end
-    end
-  end
-
-  # Factory Method is a design pattern, not a Ruby language feature.
-  # One way to implement this pattern in Ruby is via class methods --
-  # that is, methods defined on the class (Temperature) rather than
-  # on individual instances of the class.
-  describe "can be constructed via factory methods" do
-
-    it "in degrees celsius" do
-      Temperature.from_celsius(50).in_celsius.should == 50
-      Temperature.from_celsius(50).in_fahrenheit.should == 122
-    end
-
-    it "in degrees fahrenheit" do
-      Temperature.from_fahrenheit(50).in_fahrenheit.should == 50
-      Temperature.from_fahrenheit(50).in_celsius.should == 10
-    end
-
-  end
-
-  # test-driving bonus:
-  #
-  # 1. make two class methods -- ftoc and ctof
-  # 2. refactor to call those methods from the rest of the object
-  #
-  # run *all* the tests during your refactoring, to make sure you did it right
-  #
-  describe "utility class methods" do
-
-  end
-
-  # Here's another way to solve the problem!
-  describe "Temperature subclasses" do
-    describe "Celsius subclass" do
-      it "is constructed in degrees celsius" do
-        Celsius.new(50).in_celsius.should == 50
-        Celsius.new(50).in_fahrenheit.should == 122
-      end
-
-      it "is a Temperature subclass" do
-        Celsius.new(0).should be_a(Temperature)
-      end
-    end
-
-    describe "Fahrenheit subclass" do
-      it "is constructed in degrees fahrenheit" do
-        Fahrenheit.new(50).in_fahrenheit.should == 50
-        Fahrenheit.new(50).in_celsius.should == 10
-      end
-
-      it "is a Temperature subclass" do
-        Fahrenheit.new(0).should be_a(Temperature)
-      end
-    end
-  end
-
-end
-
-
-
- - - diff --git a/10_temperature_object/temperature_object_spec.rb b/10_temperature_object/temperature_object_spec.rb index 1f87211dc..d2f0c35cc 100644 --- a/10_temperature_object/temperature_object_spec.rb +++ b/10_temperature_object/temperature_object_spec.rb @@ -2,7 +2,7 @@ # Take your time, don't be scared to ask for help– # we're pushing your limits, if you can do it you'll be in an amazing position moving forward. -# Remember one degree fahrenheit is 5/9 of one degree celsius, +# Remember one degree fahrenheit is 5/9 of one degree celsius, # and the freezing point of water is 0 degrees celsius but 32 degrees fahrenheit. require "temperature" @@ -13,34 +13,34 @@ describe "in degrees fahrenheit" do it "at 50 degrees" do # A hash with the key "f" is being passed in. - Temperature.new({:f => 50}).to_fahrenheit.should == 50 + expect(Temperature.new({:f => 50}).to_fahrenheit).to eq 50 # Remember, new is synonymous with initialize. # An example might help: - # + # # class Person # def initialize(name) # @name = name # end # end - # + # # Person.new("Alex") end describe "and correctly convert to celsius" do it "at freezing" do - Temperature.new({:f => 32}).to_celsius.should == 0 + expect(Temperature.new({:f => 32}).to_celsius).to eq(0) end it "at boiling" do - Temperature.new({:f => 212}).to_celsius.should == 100 + expect(Temperature.new({:f => 212}).to_celsius).to eq(100) end it "at body temperature" do - Temperature.new({:f => 98.6}).to_celsius.should == 37 + expect(Temperature.new({:f => 98.6}).to_celsius).to eq(37) end it "at an arbitrary temperature" do - Temperature.new({:f => 68}).to_celsius.should == 20 + expect(Temperature.new({:f => 68}).to_celsius).to eq(20) end end end @@ -48,16 +48,16 @@ describe "in degrees celsius" do it "at 50 degrees" do # Now a hash with the key "c" is being passed in. - Temperature.new({:c => 50}).to_celsius.should == 50 + expect(Temperature.new({:c => 50}).to_celsius).to eq(50) end describe "and correctly convert to fahrenheit" do it "at freezing" do - Temperature.new({:c => 0}).to_fahrenheit.should == 32 + expect(Temperature.new({:c => 0}).to_fahrenheit).to eq(32) end it "at boiling" do - Temperature.new({:c => 100}).to_fahrenheit.should == 212 + expect(Temperature.new({:c => 100}).to_fahrenheit).to eq(212) end end end @@ -66,11 +66,11 @@ describe "can be constructed via factory methods" do it "in degrees celsius" do - Temperature.in_celsius(50).to_celsius.should == 50 - Temperature.in_celsius(50).to_fahrenheit.should == 122 + expect(Temperature.in_celsius(50).to_celsius).to eq(50) + expect(Temperature.in_celsius(50).to_fahrenheit).to eq(122) # Nothing different is being achieved with these two lines, # they're just a different way of doing the same thing, - # that requires you to write your code another way. + # that requires you to write your code another way. # # Remember, methods called on a class are called class methods. # Here's an example: @@ -85,8 +85,8 @@ end it "in degrees fahrenheit" do - Temperature.in_fahrenheit(50).to_fahrenheit.should == 50 - Temperature.in_fahrenheit(50).to_celsius.should == 10 + expect(Temperature.in_fahrenheit(50).to_fahrenheit).to eq(50) + expect(Temperature.in_fahrenheit(50).to_celsius).to eq(10) end end @@ -95,8 +95,8 @@ describe "Temperature subclasses" do describe "Celsius subclass" do it "is constructed in degrees celsius" do - Celsius.new(50).to_celsius.should == 50 - Celsius.new(50).to_fahrenheit.should == 122 + expect(Celsius.new(50).to_celsius).to eq(50) + expect(Celsius.new(50).to_fahrenheit).to eq(122) # Again, this is a different way of doing the same thing. # Instead of initializing a new Temperature with a hash that has a key "c", # we're just initializing a new Celsius. @@ -104,7 +104,7 @@ it "is a Temperature subclass" do # In other words, Celsius *inherits* from Temperature. - Celsius.new(0).should be_a(Temperature) + expect(Celsius.new(0)).to be_a(Temperature) # Remember class inheritance? # # class Person < Mammal @@ -114,12 +114,12 @@ describe "Fahrenheit subclass" do it "is constructed in degrees fahrenheit" do - Fahrenheit.new(50).to_fahrenheit.should == 50 - Fahrenheit.new(50).to_celsius.should == 10 + expect(Fahrenheit.new(50).to_fahrenheit).to eq(50) + expect(Fahrenheit.new(50).to_celsius).to eq(10) end it "is a Temperature subclass" do - Fahrenheit.new(0).should be_a(Temperature) + expect(Fahrenheit.new(0)).to be_a(Temperature) end end end diff --git a/Gemfile b/Gemfile index 3821439e2..9627a3b4b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source "https://rubygems.org" gem "rake" -gem "rspec", ">=2.0" +gem "rspec", "~>3.0.0" diff --git a/README.md b/README.md new file mode 100644 index 000000000..1d375baf9 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Learn Ruby + +originally forked from [https://github.com/alexch/learn_ruby](https://github.com/alexch/learn_ruby) + +## Getting started + +Since this project has a `Gemfile`, you can run `bundler` to install all the required gems! + + +Start by installing the bundler gem: + +```bash +$ gem install bundler +``` + +Since Bundler installs a new command line command, you'll need to the following command to get it all working with `rbenv`. + +```bash +$ rbenv rehash +``` + +Now you're ready to run Bundler and install all your project gem dependencies. + +```bash +$ bundle install +``` + +This should install all the gems you need. + +Once you're done, run + +```bash +$ rbenv rehash +``` + +again. + +## Running the tests + +Each directory represents a small project and to run the tests you'll need to be in that directory. For example, to try the first assignment, you'll `cd` into it. + +```bash +$ cd 00_hello +``` + +Once you're in the mini project directory, you can type the following to run the whole test suite. + +```bash +$ rake +``` + +or to run individual test files, you could also use the `rspec` command followed by the file name. + +```bash +$ rspec hello_spec.rb +``` diff --git a/Rakefile b/Rakefile index 22162469d..fc9f1c4a5 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,5 @@ # This Rakefile has all the right settings to run the tests inside each lab -gem 'rspec', '~>2' +gem 'rspec', '>=2' require 'rspec/core/rake_task' task :default => :spec diff --git a/assets/style.css b/assets/style.css deleted file mode 100644 index c12bab2a4..000000000 --- a/assets/style.css +++ /dev/null @@ -1,113 +0,0 @@ -/* Solarized Palette http://ethanschoonover.com/solarized */ -/* Font Stacks http://www.artsiteframework.com/guide/fontstacks.php */ -body { - background-color: white; - font-family: Optima, Candara, "Trebuchet MS", sans-serif; - margin: 0px; - font-size: 15px; - line-height: 19px; } - -a, a:visited { - color: #268bd2; } - -a:hover { - text-decoration: underline; } - -a { - text-decoration: none; } - -.content { - padding: 0 2em 0 18em; - min-height: 30em; - min-width: 20em; - max-width: 44em; - margin: 1em auto; } - .content h1, .content h2, .content h3 { - font-family: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", Verdana, sans-serif; - margin-left: -1em; } - .content h1 { - text-shadow: #999 1px 1px 1px; - padding: .5em .25em; - margin-top: 1em; } - .content h2 { - margin-top: 1em; - border-bottom: #268bd2 1px dotted; } - .content pre { - overflow-x: auto; } - -.header, .footer { - font-size: 80%; - padding: .25em; - background-color: #f2f2f2; } - -.header { - border-bottom: 1px solid #002b36; - text-align: left; } - .header h1 { - color: #800000; - margin: 0 0 -8px 0; - padding: 0; - font: 30px/48px Optima, Candara, "Trebuchet MS", sans-serif; - letter-spacing: 0; } - .header h2 { - margin: 0 0 4px 13px; - padding: 0; - font: 10pt Optima, Candara, "Trebuchet MS", sans-serif; - color: #686868; - letter-spacing: 0; - font-variant: small-caps; } - .header a, .header a:visited { - color: #800000; - text-decoration: none; } - .header a:hover { - color: #37030B; - text-decoration: none; } - -.footer { - border-top: 1px solid #002b36; - text-align: center; } - -.nav { - float: left; - margin: 1em; - padding: 0 1em 1em; - width: 14em; - font-size: 75%; } - -.nav { - background: -webkit-gradient(linear, left bottom, left top, color-stop(0.15, white), color-stop(0.85, #f2f2f2)); - background: -moz-linear-gradient(center bottom, white 15%, #f2f2f2 85%); - -moz-border-radius: 10px; - border-radius: 10px; - border: 1px solid black; } - -.rspec_file > .tests { - position: relative; } - .rspec_file > .tests a.raw_file { - float: right; - position: absolute; - right: 0; - padding: 2px 4px; - margin: 3px; - border: 1px solid #666; - background: #ddd; } - -pre { - font-family: "Lucida Sans Typewriter Regular", "lucida console", monaco, "andale mono", "bitstream vera sans mono", consolas, "DejaVu Sans Mono", Courier, "Courier New", monospace; - background-color: #e9e9ff; - padding: .5em 1em; - border: 1px solid #93a1a1; } - -code { - font-family: "Lucida Sans Typewriter Regular", "lucida console", monaco, "andale mono", "bitstream vera sans mono", consolas, "DejaVu Sans Mono", Courier, "Courier New", monospace; - background-color: #efefff; } - -pre > code { - background-color: #e9e9ff; } - -li > p:nth-child(0) { - margin: 0; } - -ul li ul li { - margin-top: .1em; - margin-bottom: 1em; } diff --git a/bonus_dictionary/dictionary_spec.rb b/bonus_dictionary/dictionary_spec.rb index 9692be2ba..0bf301914 100644 --- a/bonus_dictionary/dictionary_spec.rb +++ b/bonus_dictionary/dictionary_spec.rb @@ -6,57 +6,57 @@ end it 'is empty when created' do - @d.entries.should == {} + expect(@d.entries).to eq({}) end it 'can add whole entries with keyword and definition' do @d.add('fish' => 'aquatic animal') - @d.entries.should == {'fish' => 'aquatic animal'} - @d.keywords.should == ['fish'] + expect(@d.entries).to eq({'fish' => 'aquatic animal'}) + expect(@d.keywords).to eq(['fish']) end it 'add keywords (without definition)' do @d.add('fish') - @d.entries.should == {'fish' => nil} - @d.keywords.should == ['fish'] + expect(@d.entries).to eq({'fish' => nil}) + expect(@d.keywords).to eq(['fish']) end it 'can check whether a given keyword exists' do - @d.include?('fish').should be_false + @d.include?('fish').to be(false) end it "doesn't cheat when checking whether a given keyword exists" do - @d.include?('fish').should be_false # if the method is empty, this test passes with nil returned + expect(@d.include?('fish')).to be(false) # if the method is empty, this test passes with nil returned @d.add('fish') - @d.include?('fish').should be_true # confirms that it actually checks - @d.include?('bird').should be_false # confirms not always returning true after add + expect(@d.include?('fish')).to be(true) # confirms that it actually checks + expect(@d.include?('bird')).to be(false) # confirms not always returning true after add end it "doesn't include a prefix that wasn't added as a word in and of itself" do @d.add('fish') - @d.include?('fi').should be_false + expect(@d.include?('fi')).to be(false) end it "doesn't find a word in empty dictionary" do - @d.find('fi').should be_empty # {} + expect(@d.find('fi')).to be_empty # {} end it 'finds nothing if the prefix matches nothing' do @d.add('fiend') @d.add('great') - @d.find('nothing').should be_empty + expect(@d.find('nothing')).to be_empty end it "finds an entry" do @d.add('fish' => 'aquatic animal') - @d.find('fish').should == {'fish' => 'aquatic animal'} + expect(@d.find('fish')).to eq({'fish' => 'aquatic animal'}) end it 'finds multiple matches from a prefix and returns the entire entry (keyword + definition)' do @d.add('fish' => 'aquatic animal') @d.add('fiend' => 'wicked person') @d.add('great' => 'remarkable') - @d.find('fi').should == {'fish' => 'aquatic animal', 'fiend' => 'wicked person'} + expect(@d.find('fi')).to eq({'fish' => 'aquatic animal', 'fiend' => 'wicked person'}) end it 'lists keywords alphabetically' do @@ -64,6 +64,6 @@ @d.add('fish' => 'aquatic animal') @d.add('apple' => 'fruit') # Enter %w(apple fish zebra) in irb and see what happens - @d.keywords.should == %w(apple fish zebra) + expect(@d.keywords).to eq(%w(apple fish zebra)) end end diff --git a/bonus_dictionary/index.html b/bonus_dictionary/index.html deleted file mode 100644 index 778d45ee2..000000000 --- a/bonus_dictionary/index.html +++ /dev/null @@ -1,128 +0,0 @@ - - - Test-First Teaching: learn_ruby: dictionary - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

dictionary

-

Topics

- -
    -
  • Hash
  • -
  • Array
  • -
  • instance variables
  • -
  • regular expressions
  • -
- -
-
-

Tests

-dictionary_spec.rb -
-require 'dictionary'
-
-describe Dictionary do
-  before do
-    @d = Dictionary.new
-  end
-
-  it 'is empty when created' do
-    @d.entries.should == {}
-  end
-
-  it 'can add whole entries with keyword and definition' do
-    @d.add('fish' => 'aquatic animal')
-    @d.entries.should == {'fish' => 'aquatic animal'}
-    @d.keywords.should == ['fish']
-  end
-
-  it 'add keywords (without definition)' do
-    @d.add('fish')
-    @d.entries.should == {'fish' => nil}
-    @d.keywords.should == ['fish']
-  end
-
-  it 'can check whether a given keyword exists' do
-    @d.include?('fish').should be_false
-  end
-
-  it "doesn't cheat when checking whether a given keyword exists" do
-    @d.include?('fish').should be_false # if the method is empty, this test passes with nil returned
-    @d.add('fish')
-    @d.include?('fish').should be_true # confirms that it actually checks
-    @d.include?('bird').should be_false # confirms not always returning true after add
-  end
-
-  it "doesn't include a prefix that wasn't added as a word in and of itself" do
-    @d.add('fish')
-    @d.include?('fi').should be_false
-  end
-
-  it "doesn't find a word in empty dictionary" do
-    @d.find('fi').should be_empty # {}
-  end
-
-  it 'finds nothing if the prefix matches nothing' do
-    @d.add('fiend')
-    @d.add('great')
-    @d.find('nothing').should be_empty
-  end
-
-  it "finds an entry" do
-    @d.add('fish' => 'aquatic animal')
-    @d.find('fish').should == {'fish' => 'aquatic animal'}
-  end
-
-  it 'finds multiple matches from a prefix and returns the entire entry (keyword + definition)' do
-    @d.add('fish' => 'aquatic animal')
-    @d.add('fiend' => 'wicked person')
-    @d.add('great' => 'remarkable')
-    @d.find('fi').should == {'fish' => 'aquatic animal', 'fiend' => 'wicked person'}
-  end
-
-  it 'lists keywords alphabetically' do
-    @d.add('zebra' => 'African land animal with stripes')
-    @d.add('fish' => 'aquatic animal')
-    @d.add('apple' => 'fruit')
-    @d.keywords.should == %w(apple fish zebra)
-  end
-
-  it 'can produce printable output like so: [keyword] "definition"' do
-    @d.add('zebra' => 'African land animal with stripes')
-    @d.add('fish' => 'aquatic animal')
-    @d.add('apple' => 'fruit')
-    @d.printable.should == %Q{[apple] "fruit"\n[fish] "aquatic animal"\n[zebra] "African land animal with stripes"}
-  end
-end
-
-
-
- - - diff --git a/bonus_rpn_calculator/index.html b/bonus_rpn_calculator/index.html deleted file mode 100644 index b19f645d7..000000000 --- a/bonus_rpn_calculator/index.html +++ /dev/null @@ -1,196 +0,0 @@ - - - Test-First Teaching: learn_ruby: rpn_calculator - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

rpn_calculator

-

Topics

- -
    -
  • arrays
  • -
  • arithmetic
  • -
  • strings
  • -
- - -

RPN Calculator

- -

"RPN" stands for "Reverse Polish Notation". (See the wikipedia entry for more information on this colorful term.) Briefly, in an RPN world, instead of using normal "infix" notation, e.g.

- -
2 + 2
-
- -

you use "postfix" notation, e.g.

- -
2 2 +
-
- -

While this may seem bizarre, there are some advantages to doing things this way. For one, you never need to use parentheses, since there is never any ambiguity as to what order to perform operations in. The rule is, you always go from the back, or the left side.

- -
1 + 2 * 3 =>
-(1 + 2) * 3 or
-1 + (2 * 3)
-
-1 2 + 3 * => (1 + 2) * 3
-1 2 3 * + => 1 + (2 * 3)
-
- -

Another advantage is that you can represent any mathematical formula using a simple and elegant data structure, called a stack).

- -

Hints

- -

Ruby doesn't have a built-in stack, but the standard Array has all the methods you need to emulate one (namely, push and pop, and optionally size).

-
-
-

Tests

-rpn_calculator_spec.rb -
-# See
-# * <http://en.wikipedia.org/wiki/Reverse_Polish_notation>
-# * <http://www.calculator.org/rpn.aspx>
-#
-require "rpn_calculator"
-
-describe RPNCalculator do
-
-  attr_accessor :calculator
-
-  before do
-    @calculator = RPNCalculator.new
-  end
-
-  it "adds two numbers" do
-    calculator.push(2)
-    calculator.push(3)
-    calculator.plus
-    calculator.value.should == 5
-  end
-
-  it "adds three numbers" do
-    calculator.push(2)
-    calculator.push(3)
-    calculator.push(4)
-    calculator.plus
-    calculator.value.should == 7
-    calculator.plus
-    calculator.value.should == 9
-  end
-
-  it "subtracts the second number from the first number" do
-    calculator.push(2)
-    calculator.push(3)
-    calculator.minus
-    calculator.value.should == -1
-  end
-
-  it "adds and subtracts" do
-    calculator.push(2)
-    calculator.push(3)
-    calculator.push(4)
-    calculator.minus
-    calculator.value.should == -1
-    calculator.plus
-    calculator.value.should == 1
-  end
-
-  it "multiplies and divides" do
-    calculator.push(2)
-    calculator.push(3)
-    calculator.push(4)
-    calculator.divide
-    calculator.value.should == (3.0 / 4.0)
-    calculator.times
-    calculator.value.should == 2.0 * (3.0 / 4.0)
-  end
-
-  it "resolves operator precedence unambiguously" do
-    # 1 2 + 3 * => (1 + 2) * 3
-    calculator.push(1)
-    calculator.push(2)
-    calculator.plus
-    calculator.push(3)
-    calculator.times
-    calculator.value.should == (1+2)*3
-
-    # 1 2 3 * + => 1 + (2 * 3)
-    calculator.push(1)
-    calculator.push(2)
-    calculator.push(3)
-    calculator.times
-    calculator.plus
-    calculator.value.should == 1+(2*3)
-  end
-
-  it "fails informatively when there's not enough values stacked away" do
-    expect {
-      calculator.plus
-    }.to raise_error("calculator is empty")
-
-    expect {
-      calculator.minus
-    }.to raise_error("calculator is empty")
-
-    expect {
-      calculator.times
-    }.to raise_error("calculator is empty")
-
-    expect {
-      calculator.divide
-    }.to raise_error("calculator is empty")
-  end
-
-  # extra credit
-  it "tokenizes a string" do
-    calculator.tokens("1 2 3 * + 4 5 - /").should ==
-      [1, 2, 3, :*, :+, 4, 5, :-, :/]
-  end
-
-  # extra credit
-  it "evaluates a string" do
-    calculator.evaluate("1 2 3 * +").should ==
-      ((2 * 3) + 1)
-
-    calculator.evaluate("4 5 -").should ==
-      (4 - 5)
-
-    calculator.evaluate("2 3 /").should ==
-      (2.0 / 3.0)
-
-    calculator.evaluate("1 2 3 * + 4 5 - /").should ==
-      (1.0 + (2 * 3)) / (4 - 5)
-  end
-
-end
-
-
-
- - - diff --git a/bonus_rpn_calculator/rpn_calculator_spec.rb b/bonus_rpn_calculator/rpn_calculator_spec.rb index 9b6d06b86..c77cd6b09 100644 --- a/bonus_rpn_calculator/rpn_calculator_spec.rb +++ b/bonus_rpn_calculator/rpn_calculator_spec.rb @@ -1,5 +1,5 @@ -# "RPN" stands for "Reverse Polish Notation". -# (See the wikipedia entry: http://en.wikipedia.org/wiki/Reverse_Polish_notation) +# "RPN" stands for "Reverse Polish Notation". +# (See the wikipedia entry: http://en.wikipedia.org/wiki/Reverse_Polish_notation) # Briefly, in an RPN world, instead of using normal "infix" notation, e.g. # # 2 + 2 @@ -8,9 +8,9 @@ # # 2 2 + # -# While this may seem bizarre, there are some advantages to doing things this way. -# For one, you never need to use parentheses, since there is never any ambiguity -# as to what order to perform operations in. The rule is, you always go from the back, +# While this may seem bizarre, there are some advantages to doing things this way. +# For one, you never need to use parentheses, since there is never any ambiguity +# as to what order to perform operations in. The rule is, you always go from the back, # or the left side. # # 1 + 2 * 3 => @@ -20,8 +20,8 @@ # 1 2 + 3 * => (1 + 2) * 3 # 1 2 3 * + => 1 + (2 * 3) # -# Another advantage is that you can represent any mathematical formula -# using a simple and elegant data structure, called a stack +# Another advantage is that you can represent any mathematical formula +# using a simple and elegant data structure, called a stack # (http://en.wikipedia.org/wiki/Stack_(data_structure)). # # Hint: @@ -33,17 +33,13 @@ describe RPNCalculator do - attr_accessor :calculator - - before do - @calculator = RPNCalculator.new - end + let!(:calculator) {RPNCalculator.new} it "adds two numbers" do calculator.push(2) calculator.push(3) calculator.plus - calculator.value.should == 5 + expect(calculator.value).to eq(5) end it "adds three numbers" do @@ -51,16 +47,16 @@ calculator.push(3) calculator.push(4) calculator.plus - calculator.value.should == 7 + expect(calculator.value).to eq(7) calculator.plus - calculator.value.should == 9 + expect(calculator.value).to eq(9) end it "subtracts the second number from the first number" do calculator.push(2) calculator.push(3) calculator.minus - calculator.value.should == -1 + expect(calculator.value).to eq(-1) end it "adds and subtracts" do @@ -68,9 +64,9 @@ calculator.push(3) calculator.push(4) calculator.minus - calculator.value.should == -1 + expect(calculator.value).to eq(-1) calculator.plus - calculator.value.should == 1 + expect(calculator.value).to eq(1) end it "multiplies and divides" do @@ -78,9 +74,9 @@ calculator.push(3) calculator.push(4) calculator.divide - calculator.value.should == (3.0 / 4.0) + expect(calculator.value).to eq((3.0 / 4.0)) calculator.times - calculator.value.should == 2.0 * (3.0 / 4.0) + expect(calculator.value).to eq(2.0 * (3.0 / 4.0)) end it "resolves operator precedence unambiguously" do @@ -90,7 +86,7 @@ calculator.plus calculator.push(3) calculator.times - calculator.value.should == (1+2)*3 + expect(calculator.value).to eq((1+2)*3) # 1 2 3 * + => 1 + (2 * 3) calculator.push(1) @@ -98,7 +94,7 @@ calculator.push(3) calculator.times calculator.plus - calculator.value.should == 1+(2*3) + expect(calculator.value).to eq(1+(2*3)) end it "fails informatively when there's not enough values stacked away" do @@ -121,23 +117,18 @@ # Extra Credit: it "tokenizes a string" do - calculator.tokens("1 2 3 * + 4 5 - /").should == - [1, 2, 3, :*, :+, 4, 5, :-, :/] + expect(calculator.tokens("1 2 3 * + 4 5 - /")).to eq([1, 2, 3, :*, :+, 4, 5, :-, :/]) end # Extra Credit: it "evaluates a string" do - calculator.evaluate("1 2 3 * +").should == - ((2 * 3) + 1) + expect(calculator.evaluate("1 2 3 * +")).to eq(((2 * 3) + 1)) - calculator.evaluate("4 5 -").should == - (4 - 5) + expect(calculator.evaluate("4 5 -")).to eq((4 - 5)) - calculator.evaluate("2 3 /").should == - (2.0 / 3.0) + expect(calculator.evaluate("2 3 /")).to eq((2.0 / 3.0)) - calculator.evaluate("1 2 3 * + 4 5 - /").should == - (1.0 + (2 * 3)) / (4 - 5) + expect(calculator.evaluate("1 2 3 * + 4 5 - /")).to eq((1.0 + (2 * 3)) / (4 - 5)) end end diff --git a/index.html b/index.html deleted file mode 100644 index 9e4c3dcf6..000000000 --- a/index.html +++ /dev/null @@ -1,224 +0,0 @@ - - - Test-First Teaching: learn_ruby: learn_ruby - - - -
-

TestFirst.org

-

the home of test-first teaching

-
- -

learn_ruby

-

Learn Ruby Test-First

- -

Setup

- - - - -

Using These Exercises

- -

Your course directory has a list of lab directories. Each -directory has a spec file. You will write all the code to make all the specs -in it pass.

- -

To get your feet wet in this process, go into the "hello" lab with cd -00_hello and read the detailed instructions in its index.html file.

- -

If you got through "hello", then congratulations! Now it's time to go to the -next directory (whose name begins with 01_) and start learning Ruby!

- -

Course Outline

- -

Each course is different, so check with your instructor for details on the -curriculum he or she has chosen. Here is a survey of a few of the labs:

- - - - -

Advanced Setup

- -

After you're in the swing of things, you can read about advanced setup techniques like pulling changes and forking. But don't worry about it at first.

- -

Problems? Questions?

- -

First, ask your neighbor. Then, ask your instructor.

- -

Then ask Google (seriously!). If there's an error, try copying the error string and pasting it into a Google search box. If that doesn't help, do a search on one of these sites:

- - - - -

You can also find help at the TestFirst.org site or the Test-First Teaching mailing list.

- -

And many related lectures, notes and videos are at http://CodeLikeThis.com.

- -

Remember, if you post a technical question online, you should

- -
    -
  1. Include version numbers:

    - -
     $ ruby -v
    - ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
    -
  2. -
  3. Note where you have already looked for an answer

  4. -
  5. If you can, include code snippets that reproduce the problem in isolation
  6. -
- - -

Solutions and Submissions

- -

This Github repo (learn_ruby) is generated from a different Github repo, http://github.com/ultrasaurus/test-first-teaching.

- -

If you want to see how other students solved the problem, go to that repo and click around. (I'm not providing a direct link because I don't want it to be too easy to cheat!)

- -

If you want to submit a patch or a solution, please fork the Test-First Teaching repo and submit a Pull Request from there.

- -

Also,

- -

Resources

- -

Here is a broad survey of many resources you may find useful. Don't try to read them all! Just browse around when you feel like learning more about Ruby.

- -

Learning Ruby via Tests (and/or Interactively)

- - - - -

Learning Ruby and Programming

- - - - -

Test-Driven Development

- - - - -

Online Ruby References

- - - - -

Other good resources

- - - - -

Credits

- - - -
- - -