Skip to content

Commit 402fb66

Browse files
author
Adam Jonas
committed
Merge pull request #12 from drewprice/drewprice-1438176461
Updated README.md
2 parents 65e0e56 + 2f44c7d commit 402fb66

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The next line:
115115

116116
is the RSpec language and can basically be ignored for now beyond the actual semantics and meaning. We are simply saying, via valid Ruby, that this test describes the `current_age_for_birth_year` method.
117117

118-
The only things that are required in this line of code are the `describe` RSpec method and the Ruby `do` keyword, the rest of this line is entirely arbitrary and of our own design. After all `current_age_for_birth_year method`, is a String of data and could not possibly matter to Ruby because it is not interpreted, it's just data.
118+
The only things that are required in this line of code are the `describe` RSpec method and the Ruby `do` keyword, the rest of this line is entirely arbitrary and of our own design. After all, `current_age_for_birth_year method` is a String of data and could not possibly matter to Ruby because it is not interpreted, it's just data.
119119

120120
When we write tests we use the `describe` RSpec method and strings to describe what we are testing. This code is entirely for you, the programmer, and has very little meaning to RSpec or Ruby.
121121

@@ -165,7 +165,7 @@ end
165165

166166
**A test is always going to be about setting up a state with a known result and comparing that known result or expectation to the behavior of your program, thus ensuring that your program behaves as you expected.**
167167

168-
There are many kind of tests, and test-driven development and RSpec are very complex topics. Just focus on the semantics and meaning of the `*_spec.rb` files for now. It's a tremendously valuable skill to be introduced to this early.
168+
There are many kinds of tests, and test-driven development and RSpec are very complex topics. Just focus on the semantics and meaning of the `*_spec.rb` files for now. It's a tremendously valuable skill to be introduced to this early.
169169

170170
### Running Our Tests
171171

@@ -210,7 +210,7 @@ current_age_for_birth_year method
210210
returns the age of a person based on the year of birth (FAILED - 1)
211211
```
212212
213-
Those lines are summaries of what we are testing and what failed. They correspond directly to the strings provided to `describe` and `it` and are simply there to provide context.
213+
Those lines are summaries of what we are testing and what failed. They correspond directly to the strings provided to `describe` and `it`, and they are simply there to provide context.
214214
215215
```bash
216216
1) current_age_for_birth_year method returns the age of a person based on the year of birth
@@ -242,7 +242,7 @@ The above line raises the line of code in our test suite that created the failur
242242
# ./spec/current_age_for_birth_year_spec.rb:5:in `block (2 levels) in <top (required)>'
243243
```
244244

245-
Before writing any code, our test suite is failing because a line of code within it:
245+
Before writing any code, our test suite is failing because of a line of code within it:
246246

247247
`age_of_person = current_age_for_birth_year(1984)`.
248248

@@ -254,13 +254,13 @@ It's totally cool to have errors—a big part of programming is simply getting p
254254

255255
### Reading Errors And Making Our Tests Pass
256256

257-
So, we conceptually understand what we're trying to build, a method called `current_age_for_birth_year`, that when given an argument of a year of birth, `current_age_for_birth_year(1984)`, returns the age of a person, `31`. Our test suite actually tries to execute this code and compares the result of it to the desired outcome, failing until the expectation and the outcome are equal.
257+
So, we conceptually understand what we're trying to build: a method called `current_age_for_birth_year`, that when given an argument of a year of birth, `current_age_for_birth_year(1984)`, returns the age of a person, `31`. Our test suite actually tries to execute this code and compares the result of it to the desired outcome, failing until the expectation and the outcome are equal.
258258
259-
The first error thrown by the test suite is that our code, defined in `current_age_for_birth_year.rb`, should have defined a method called `current_age_for_birth_year`, but did not resulting in a `NoMethodError`.
259+
The first error thrown by the test suite is that our code, defined in `current_age_for_birth_year.rb`, should have defined a method called `current_age_for_birth_year`, but did not, resulting in a `NoMethodError`.
260260
261261
Let's fix this error by defining a method in `current_age_for_birth_year.rb` called `current_age_for_birth_year`.
262262

263-
Add the following to the file: `current_age_for_birth_year.rb`
263+
Add the following to the file, `current_age_for_birth_year.rb`:
264264

265265
```ruby
266266
def current_age_for_birth_year
@@ -280,7 +280,7 @@ Save the file and go back to your terminal and run the `learn` command. You'll s
280280
281281
#### `ArgumentError:`
282282
283-
Our tests are still failing, but for a new reason. Previously we lacked the method definition. Now we have the method defined, however, our tests are complaining that the line of code `age_of_person = current_age_for_birth_year(1984)` invoked the method `current_age_for_birth_year` incorrectly because it called that method with an argument but the method *we* defined does not accept an argument.
283+
Our tests are still failing, but for a new reason. Previously we lacked the method definition. Now we have the method defined; however, our tests are complaining that the line of code, `age_of_person = current_age_for_birth_year(1984)`, invoked the method `current_age_for_birth_year` incorrectly because it called that method with an argument but the method *we* defined does not accept an argument.
284284
285285
This results in an `ArgumentError`.
286286
@@ -361,9 +361,9 @@ Run this program with `ruby how_old_are_you.rb`. There shouldn't be any errors i
361361

362362
What this program does is load the code in our original program `current_age_for_birth_year.rb`. It then prints the string `"What year were you born?"`. It prompts the user for input via the `gets` method and converts the input to an integer with `to_i`.
363363

364-
The program then invokes (or calls) the method `current_age_for_birth_year`. The cool part is that this method is not defined within this file, rather, it was defined in a singular, simple file, and just loaded and used in this more complex program. That's the heart of abstraction and encapsulation; `how_old_are_you.rb` doesn't need to know how `current_age_for_birth_year.rb` works, it just gets to load the code and rely that it behaves as expected and defined in the tests for that library.
364+
The program then invokes (or calls) the method `current_age_for_birth_year`. The cool part is that this method is not defined within this file, rather, it was defined in a singular, simple file, and just loaded and used in this more complex program. That's the heart of abstraction and encapsulation: `how_old_are_you.rb` doesn't need to know how `current_age_for_birth_year.rb` works, it just gets to load the code and trusts that it behaves as expected, as it was defined in the tests for that library.
365365

366-
This is the architecture of real applications. Each file is a singular, simple, component or "unit of work". The files are loaded together by an execution file and the discrete units execute together to make complex and amazing applications.
366+
This is the architecture of real applications. Each file is a singular, simple component or "unit of work". The files are loaded together by an execution file and the discrete units execute together to make complex and amazing applications.
367367

368368
#### Our Tests Are Only Temporarily Correct
369369

@@ -400,7 +400,7 @@ That would be a better implementation of `current_age_for_birth_year` as it is m
400400

401401
## Conclusion
402402

403-
Remember, for now you are not being asked to write your own tests. The important take away here is how to *read* tests and understand error messages that get outputted as a result of running them. You can refer back to earlier lessons (see below) to review those skills.
403+
Remember, for now, you are not being asked to write your own tests. The important take away here is how to *read* tests and understand error messages that get outputted as a result of running them. You can refer back to earlier lessons (see below) to review those skills.
404404

405405
## Resources
406406

0 commit comments

Comments
 (0)