Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drbragg/user-account-validator
Practice with error and exception handling
https://github.com/drbragg/user-account-validator
Last synced: 10 days ago
JSON representation
Practice with error and exception handling
- Host: GitHub
- URL: https://github.com/drbragg/user-account-validator
- Owner: DRBragg
- Created: 2017-07-27T13:22:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-27T13:24:02.000Z (over 7 years ago)
- Last Synced: 2024-11-09T01:45:48.079Z (2 months ago)
- Language: Ruby
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Introduction
We have a data set of user accounts. However, some user data is missing or incomplete.
### Instructions
#### Part 1
Create a `UserAccountValidator` class, that takes in a hash to its constructor.
The hash should have the following keys.* `:email`
* `:username`
* `:name`Assign the values of theses keys to instance variables and create readers for them.
#### Part 2
The following conditions should `raise` an exception:
* email is missing.
* email does not contain an `@` symbol.
* username is missing.Use the simple `raise 'message'` format for raising an exception.
#### Part 3
Create a custom error class, which inherits from `StandardError`, to handle
when emails are missing. Give the class a descriptive name.#### Part 4
In the `runner.rb` file, use a `begin..rescue..end` code block to rescue all
`StandardError`s, and print out the details of what went wrong to the console.#### Part 5
Write unit test for the `UserAccountValidator` class.
### Resources
* [StandardError - ruby-doc.org](https://ruby-doc.org/core/StandardError.html)
* [Exception - ruby-doc.org](https://ruby-doc.org/core/Exception.html)
* [Ruby Error Handling, Beyond the Basics](https://www.sitepoint.com/ruby-error-handling-beyond-basics/)
* [Exception Handling - Dan Nguyen](http://ruby.bastardsbook.com/chapters/exception-handling/)
* [Ruby Exceptions - RubyLearning.com](http://rubylearning.com/satishtalim/ruby_exceptions.html)
* [RSpec raise_error matcher](https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/raise-error-matcher)