-
Notifications
You must be signed in to change notification settings - Fork 27
Sockets - Pauline & Niv #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
slack.rbWhat We're Looking For
|
| token: TOKEN, | ||
| } | ||
| response = HTTParty.get(URL, query: query_parameters)['channels'] | ||
| response.each do |channel| |
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.
Forgot to validate response.code and response.parsed_response["ok"].
| raise SlackApiError, "Error when posting #{text} to #{name}, error: #{response.parsed_response["error"]}" | ||
| end | ||
|
|
||
| return response.code == 200 && response.parsed_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.
I would consider just returning true here since you've already done the check above.
| end | ||
|
|
||
| def self.list | ||
| return @@all |
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.
While it doesn't cause a problem here generally class variables should be your tool of last resort. I probably would have only stored them in a field in Workspace instead of here and there.
| def self.load | ||
| query_parameters = { token: TOKEN } | ||
| response = HTTParty.get(BASE_URL << USERS_LIST_PATH, query: query_parameters) | ||
| response["members"].length.times do |i| |
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.
Forgot to validate response.code and response.parsed_response["ok"].
| @selected = selected | ||
| end | ||
|
|
||
| def select_channel(id_or_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.
Tiny issue: it's a little odd to use a keyword argument here since you only have a single argument.
| @selected = user | ||
| end | ||
| end | ||
| return @selected |
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.
Ruby's .find enumerable method might be helpful to clean up this code.
| describe "self.list" do | ||
|
|
||
| end | ||
| end No newline at end of file |
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 also like to see a test that verifies that self.load raises NotImplementedError.
| describe "User" do | ||
| before do | ||
| VCR.use_cassette("load_users") do | ||
| @response = SlackAPI::User.load |
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 like to see some edge case testing on User.load.
| end | ||
| end | ||
|
|
||
| describe "send message" do |
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 also like to see some edge case tests on sending messages.
| end | ||
| end | ||
|
|
||
| describe "select_user" do |
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 like a test on what happens if the user doesn't exist. Also, do you lose your selection if you attempt to select an invalid user? Should you?
slack.rbWhat We're Looking For
|
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions