-
Notifications
You must be signed in to change notification settings - Fork 26
Branches - Eve and Mira #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…lly tested in Recipient class
slack.rbWhat We're Looking For
|
1 similar comment
slack.rbWhat We're Looking For
|
| class SlackApiError < Exception; end | ||
|
|
||
| def initialize(slack_id:, name:) | ||
| raise ArgumentError unless (slack_id && name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant, keyword arguments without defaults are required.
| end | ||
|
|
||
| def self.list | ||
| raise NotImplementedError, "template method" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template method! 🎉
|
|
||
| def self.get(url, params) | ||
| response = HTTParty.get(url, query: params) | ||
| raise SlackApiError unless response['ok'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be helpful to include the error in the message and also check the response code.
| raise SlackApiError unless response['ok'] | |
| raise SlackApiError.new(response["error"]) unless response['ok'] && response.code == 200 |
| raise SlackApiError | ||
| end | ||
|
|
||
| return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning true is redundant here, since you know this succeeded if it returns.
| begin | ||
| workspace.send_message | ||
| rescue Recipient::SlackApiError | ||
| puts "Unable to send message\n\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you'd include a message you could print a more descriptive error here.
rescue Recipient::SlackApiError => api_error
puts "Unable to send message #{api_error.message}\n\n"|
|
||
| def send_message | ||
| if selected | ||
| puts "Please enter message to send to #{selected.name}: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Printing belongs in your driver code (slack.rb). Including it here makes this difficult to unit-test.
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions