-
Notifications
You must be signed in to change notification settings - Fork 26
Branches -- Angele & Paige #17
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
…ponse, added test with cassette created with bad token
…onality to workspace and tests.
…workspace_test to use VCR for show_details test.
slack.rbWhat We're Looking For
|
| /specs/cassettes/ | ||
|
|
||
| # Ignore .DS_Store | ||
| .DS_Store |
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.
You can ignore these globally:
https://coderwall.com/p/vz6ymw/how-to-globally-gitignore-ds_store
| key = ENV["API_TOKEN"] | ||
| response = HTTParty.get("https://slack.com/api/channels.info", query: {token: key , channel: @slack_id}) | ||
| if response.keys.include? "error" || response["ok"] == false | ||
| raise SlackCLI::SlackApiError |
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 nice if you'd included what the error was in the message here.
| raise SlackCLI::SlackApiError | |
| raise SlackCLI::SlackApiError.new(response["error"]) |
| if response.keys.include? "error" || response["ok"] == false | ||
| raise SlackCLI::SlackApiError.new("Message not sent due to error: #{response["error"]}") | ||
| else | ||
| 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.
I appreciate what you're doing here but since this method raises the only thing it can ever return is true so I probably wouldn't bother with returning something.
| end | ||
|
|
||
| def self.list | ||
| raise NotImplementedError.new("Self.list should be implemented in child class") |
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.
Abstract methods! 🎉
| puts "Select Channel" | ||
| print "Please enter a Channel Name or Slack ID: " | ||
| query = gets.chomp.downcase | ||
| query_result = workspace.select_channel(query) |
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.
I'd have liked to have seen the error here handled with an exception and then rescued down below. That way the message could be constructed inside of select_channel and you wouldn't need the extra check below.
Plus, it could give you to opportunity to DRY up your code by putting all of your error handling in a single begin/rescue within your until wrapping your case.
| } | ||
| ) | ||
|
|
||
| if response.keys.include? "error" || response["ok"] == false |
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.
You should be checking response.code here.
|
|
||
| def details | ||
| key = ENV["API_TOKEN"] | ||
| response = HTTParty.get("https://slack.com/api/users.info", query: {token: key , user: @slack_id}) |
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 made self.get accept parameters then you could have avoided duplicating error handling.
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions