Skip to content

Commit fb98a32

Browse files
committed
update
1 parent 361a354 commit fb98a32

6 files changed

+29
-8
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
This "book" is my attempt to teach idiomatic **Ruby** and **Test-Driven Development** (TDD).
66

7+
(spoiler: we're going to use **Minitest**, not RSpec)
8+
79
## Why?
810

911
### Why Ruby?
@@ -32,7 +34,9 @@ The chapters are presented in a sequence where new Ruby features are introduced
3234

3335
Initially the cycle may seem tedious, but as you progress through the book you'll see how productive it is to get instant feedback on your work.
3436

35-
You'll notice that the programs we'll code are really simple. That's intentional. The greatest value will be in the way we solve the problems. The tools we use, the tests we write, the way we organize our code...
37+
In the first chapters we use a [procedural programming paradigm](https://en.wikipedia.org/wiki/Procedural_programming) to show both the fundamentals of Ruby syntax and how TDD works. Once the basic Ruby concepts are addressed we start to write our code using Object-Oriented Programming.
38+
39+
You'll notice that the programs are really simple. That's intentional. The greatest value will be in the way we solve the problems. The tools we use, the tests we write, the way we organize our code...
3640

3741
If I used "real world problems", I would need to spend words explaining the problem's domain and then talk about the techniques. That would be lengthy and confusing. By keeping the problems simple, I'm sure you'll find a way to adapt the techniques to the "real world problem" you have to solve.
3842

bibliography.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ This is an **incomplete** list of books and links I consulted and/or was inspire
33
- [Learn Go with Tests](https://quii.gitbook.io/learn-go-with-tests), Chris James
44
- [The Well-Grounded Rubyist](https://www.manning.com/books/the-well-grounded-rubyist-third-edition), 3rd edition
55
- [Practical Object-Oriented Design in Ruby](https://www.poodr.com), Sandi Metz
6+
- [Test-Driven Development By Example](https://www.oreilly.com/library/view/test-driven-development/0321146530/), Kent Beck
67
- [Tidy First?](https://www.oreilly.com/library/view/tidy-first/9781098151232/), Kent Beck
78
- [Learning Test-Driven Development](https://learning.oreilly.com/library/view/learning-test-driven-development/9781098106461/), Saleem Siddiqui
8-
- [Ruby in 100 Minutes](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html), JumpstartLab
9+
- [Ruby in 100 Minutes](https://web.archive.org/web/20240115073552/http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html), JumpstartLab
910

1011
I'll be adding more references as I use them.

hello-world.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ We learn a bunch of things here.
627627
- `case` statements
628628
- how to write tests with Minitest
629629

630-
### TDD
630+
### Testing
631631

632632
The TDD process and _why_ the steps are important
633633

loops-blocks-and-strings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ git commit -m 'fix(banner): handle multiline text'
544544
- `each_line`
545545
- `chomp`
546546

547-
### TDD
547+
### Testing
548548

549549
- Reinforced TDD practices (write test first!)
550550
- After receiving a bug report:

objects-methods-and-integers.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,23 @@ Now let's start our _Decimal to Binary Converter™_ project following the TDD c
4343

4444
### Write the test first
4545

46-
We still have no idea about how to implement this converter, but by looking at the [Wikipedia page about binary numbers](https://simple.wikipedia.org/wiki/Binary_number) we can see a table with some equivalents. Here are some examples:
46+
We still have no idea about how to implement this converter, then *how can we write a test for a code that doesn't even exist?!* That's strong and valid question. The answer is: **write the test using the best interface you can think of to perform the operation**.
47+
48+
Keeping this in mind, I list here my ideas for a great interface to a function able to convert a decimal number to its binary representation:
49+
50+
- a function named `dec2bin`
51+
- it accepts an integer number as the only argument
52+
- it returns the binary representation of the given number
53+
54+
Something like this:
55+
56+
```ruby
57+
binary = dec2bin(123)
58+
```
59+
60+
Yeah, that looks good. Let's go ahead and create a test for that (inexistent) function!
61+
62+
We will need to, at least, know what would be a successful conversion. For this I use the [Wikipedia page about binary numbers](https://simple.wikipedia.org/wiki/Binary_number), where we can see a table like this:
4763

4864
| decimal | binary |
4965
| :-----: | -----: |
@@ -74,7 +90,7 @@ class TestDec2Bin < Minitest::Test
7490
end
7591
```
7692

77-
Let's run this test and see the error message.
93+
Run this test and check the error message.
7894

7995
### Error vs. Failure
8096

@@ -512,7 +528,7 @@ Let's recap what we learned in this chapter.
512528
- `gets`: read user's input
513529
- method chaining: calling multiple methods in sequence (e.g.: `number.to_i.to_s(2)`)
514530

515-
### TDD
531+
### Testing
516532

517533
- Test-first approach: write the test before implementation code.
518534
- Test Error vs. Test Failure

ruby-tooling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The Ruby community has two main testing frameworks:
1818
In this book we're going to use **Minitest**, for two reasons:
1919

2020
1. it comes with the Ruby Standard Library.
21-
2. "it doesn’t reinvent anything that ruby already provides. This means you only have to learn ruby to use minitest" - (from [minitest's README](https://github.com/minitest/minitest?tab=readme-ov-file#description-))
21+
2. you only have to know ruby to use Minitest
2222

2323
## Ruby documentation
2424

0 commit comments

Comments
 (0)