Skip to content

Commit 00b9c37

Browse files
committed
Merge pull request saasbook#17 from tansaku/master
Update README.md
2 parents 891c357 + 2a3ff2e commit 00b9c37

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

README.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ give you guidance as to which tests failed. (You can check the [RSpec
2424
documentation](http://rspec.info) to see how the `.rspec` file can be
2525
used to customize the output format.)
2626

27-
* If you want to be really cool, run `autotest`. This will run all the
28-
tests in `spec/`, but every time you edit and save your code file, the
29-
tests are automatically re-run, so you don't have to run them manually.
30-
As we'll see later, this is the first step to TDD or test-driven
31-
development: write the tests before you write the code, watch the test
32-
fail, fill in the code and save the code file, then watch the test pass!
27+
3328

3429

3530
# 1. Arrays, Hashes, and Enumerables
@@ -38,43 +33,60 @@ Check the [Ruby 2.x documentation](http://ruby-doc.org) on `Array`,
3833
`Hash` and `Enumerable` as they could help tremendously with these
3934
exercises. :-)
4035

41-
0. Define a method `sum(array)` that takes an array of integers as an argument and returns the sum of its elements. For an empty array it should return zero.
36+
0. Define a method `sum(array)` that takes an array of integers as an argument and returns the sum of its elements. For an empty array it should return zero. Run associated tests via: `$ rspec spec/part1_spec.rb:5`
4237

43-
0. Define a method `max_2_sum(array)` which takes an array of integers as an argument and returns the sum of its two largest elements. For an empty array it should return zero. For an array with just one element, it should return that element.
38+
0. Define a method `max_2_sum(array)` which takes an array of integers as an argument and returns the sum of its two largest elements. For an empty array it should return zero. For an array with just one element, it should return that element. Run associated tests via: `$ rspec spec/part1_spec.rb:23`
4439

45-
0. Define a method `sum_to_n?(array, n)` that takes an array of integers and an additional integer, n, as arguments and returns true if any two elements in the array of integers sum to n. `sum_to_n?([], n)` should return false for any value of n, by definition.
40+
0. Define a method `sum_to_n?(array, n)` that takes an array of integers and an additional integer, n, as arguments and returns true if any two elements in the array of integers sum to n. `sum_to_n?([], n)` should return false for any value of n, by definition. Run associated tests via: `$ rspec spec/part1_spec.rb:42`
4641

47-
You can check your progress by running `rspec spec/part1_spec.rb`, or
48-
just running `autotest` and leaving it running.
42+
You can check your progress on the all the above by running `$ rspec spec/part1_spec.rb`.
4943

5044
# 2. Strings and Regular Expressions
5145

5246
Check the documentation on String and Regexp as they could help tremendously with these exercises. :-)
5347

54-
0. Define a method `hello(name)` that takes a string representing a name and returns the string "Hello, " concatenated with the name.
48+
0. Define a method `hello(name)` that takes a string representing a name and returns the string "Hello, " concatenated with the name. Run associated tests via: `$ rspec -e '#hello' spec/part2_spec.rb`
5549

56-
0. Define a method `starts_with_consonant?(s)` that takes a string and returns true if it starts with a consonant and false otherwise. (For our purposes, a consonant is any letter other than A, E, I, O, U.) NOTE: be sure it works for both upper and lower case and for nonletters!
50+
0. Define a method `starts_with_consonant?(s)` that takes a string and returns true if it starts with a consonant and false otherwise. (For our purposes, a consonant is any letter other than A, E, I, O, U.) NOTE: be sure it works for both upper and lower case and for nonletters! Run associated tests via: `$ rspec -e '#starts_with_consonant?' spec/part2_spec.rb`
5751

58-
0. Define a method `binary_multiple_of_4?(s)` that takes a string and returns true if the string represents a binary number that is a multiple of 4. NOTE: be sure it returns false if the string is not a valid binary number!
52+
0. Define a method `binary_multiple_of_4?(s)` that takes a string and returns true if the string represents a binary number that is a multiple of 4. NOTE: be sure it returns false if the string is not a valid binary number! Run associated tests via: `$ rspec -e '#binary_multiple_of_4?' spec/part2_spec.rb`
5953

54+
You can check your progress on the all the above by running `$ rspec spec/part2_spec.rb`.
6055

6156
# 3. Object Oriented Basics
6257

6358

6459
Define a class `BookInStock` which represents a book with an ISBN
6560
number, `isbn`, and price of the book as a floating-point number,
66-
`price`, as attributes.
61+
`price`, as attributes. Run associated tests via: `$ rspec -e 'getters and setters' spec/part3_spec.rb`
6762

6863
The constructor should accept the ISBN number
6964
(a string, since in real life ISBN numbers can begin with zero and can
7065
include hyphens) as the first argument and price as second argument, and
7166
should raise `ArgumentError` (one of Ruby's built-in exception types) if
7267
the ISBN number is the empty string or if the price is less than or
7368
equal to zero. Include the proper getters and setters for these
74-
attributes.
69+
attributes. Run associated tests via: `$ rspec -e 'constructor' spec/part3_spec.rb`
7570

7671
Include a method `price_as_string` that returns the price of
7772
the book formatted with a leading dollar sign and two decimal places, that is, a price
7873
of 20 should format as "$20.00" and a price of 33.8 should format as
79-
"$33.80".
74+
"$33.80". Run associated tests via: `$ rspec -e '#price_as_string' spec/part3_spec.rb`
75+
76+
You can check your progress on the all the above by running `rspec spec/part3_spec.rb`.
77+
78+
## More Challenges
79+
80+
* Try getting setup with
81+
an automated test framework such as [guard](http://code.tutsplus.com/tutorials/testing-your-ruby-code-with-guard-rspec-pry--cms-19974) or [autotest](https://rubygems.org/gems/autotest). Guard or AutoTest can be set up so that
82+
they will run all the tests in `spec/`, but every time you edit and save
83+
your code file, the tests are automatically re-run, so you don't have to
84+
run them manually. As we'll see later, this is the "watch the test fail"
85+
part of the TDD or test-driven process of development: write the tests before
86+
you write the code, watch the test fail, fill in the code and save the code file,
87+
then watch the test pass!
88+
89+
* Try pairing using the [one-undermanship pair programming style](http://www.agileventures.org/remote-pair-programming/pair-programming-protocols)
90+
91+
8092

0 commit comments

Comments
 (0)