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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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