A TestCase Scenario

Learn another reason to include tests with the help of a test-case scenario.

Third reason for including tests

Let’s imagine a more sophisticated scenario. For example, if the total weight is more than a certain threshold, we might need a different kind of box, or two boxes. Or, we want to add a gift weight once we have two or more tennis balls in the cart.

With limited resources (say, we only have one hour while coding on a train), we can skip the test files and test the method manually with Pry. However, do we agree that sharing our code is better when we have a test that checks that the code works fine, so anyone can run all tests with one command and ensure everything is in place?

We’ll create lib directory and two files, shipment.rb and app.rb, the following way:

Get hands-on with 1200+ tech skills courses.