Skip to content

CoderAcademy-BRI/ruby-tdd-and-error-handling-S-Kel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Ruby TDD and Error Handling Lesson

For these two challenges, work in pairs.

Part 1: Error handling

Modify the code in errors/divide.rb to better handle errors:

  1. Print a more useful message to the user when divide by 0 occurs.
  2. Give the user 3 chances to provide valid input when they try to divide by 0.
  3. Create a method to validate that a number is always entered by the user. When a non-number is entered, use a custom error called NonNumericArgumentError to alert the user that this type of error occurred. (Hint: You can use the String is_i? method provided in the divide.rb file to complete this step).
  4. Now ask your partner to give you one of their previous challenge files, and add some error handling to it. Remember that when you refactor 'legacy code', you should do something small to leave it better than when you found it - the campsite rule!

Part 2: TDD

Continuing on from the lesson today, try the following using the code in customers/customer.rb and tests/test_customer.rb:

  1. Use TDD to implement a method to update the name of a customer (remember to create the test first!)
  2. The challenge in canvas provides another repo that you can fork and clone, then update according to the challenge instructions

To do on your own

  1. If you have time, you can checkout the Beast Mode challenge which suggests you give RSpec a try. We will cover RSpec in more detail when we start using Rails.
  2. The Beast Mode ++ challenge doesn't point to the correct link. Instead of doing that, refactor one of your other assigments to include some unit tests.

About

ruby-tdd-and-error-handling-S-Kel created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages