1f11f7ec6bcc4bb91dfa711565cb6009369e2dc9
test-doubles.md
| ... | ... | @@ -72,12 +72,18 @@ class ConverterTest < MiniTest::Test |
| 72 | 72 | @c = Converter.new(FToCConverter) |
| 73 | 73 | end |
| 74 | 74 | |
| 75 | - def test_f_to_c |
|
| 75 | + def test_convert |
|
| 76 | 76 | assert_in_delta 500, @c.convert(32), 0.01 |
| 77 | 77 | end |
| 78 | 78 | end |
| 79 | 79 | ``` |
| 80 | 80 | |
| 81 | +**NOTE:** In the real world, this is not how it's done. Why? Because in this test, _we don't care about |
|
| 82 | +FToCConverter_. All we care about is making available to the test an object that exposes a `convert` |
|
| 83 | +method that returns a specific value, so that we van validate that the main `convert` method on |
|
| 84 | +`Converter` leverages it. In short, we want to write the least amount of code to see that the plumbing |
|
| 85 | +is working. |
|
| 86 | + |
|
| 81 | 87 | ### Testing messages sent to others |
| 82 | 88 | |
| 83 | 89 | When we send a message to another object that results in a side effect, we want to verify the side effect. |