-
Notifications
You must be signed in to change notification settings - Fork 27
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
Ports - Heather and Mina #12
base: master
Are you sure you want to change the base?
Conversation
slack.rbWhat We're Looking For
|
case selection | ||
when "list channels" | ||
puts Slack::Workspace.all_channels_details | ||
when "select 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.
The way you have this here means the channel doesn't stay selected. It also means you have a lot of duplicate code in selecting users and channels and sending messages etc.
def self.get | ||
url = "https://slack.com/api/users.list" | ||
params = { | ||
token: ENV["KEY"], |
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.
In general don't name your environmental variable "KEY"
, make the name a bit more specific.
Also both the token and the URL would make great constants.
@topic = topic | ||
end | ||
|
||
def self.get |
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 could implement this method in Recipient
and inherit the behavior.
|
||
message_request = HTTParty.post(url, query: params) | ||
if message_request["ok"] == false | ||
raise ArgumentError, "Request is unsuccessful" |
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 also include the error message.
Dotenv.load | ||
|
||
module Slack | ||
class Workspace |
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 works as a collection of class methods, but if you're using all class methods, you might as well just make Workspace
a module. Instead I would suggest making Workspace
a class with the attributes @users
, @channels
and @selected
, which means you could keep track of the selected user or channel in your main app.
expect(receiver).must_be_instance_of Slack::Recipient | ||
end | ||
end | ||
|
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 also test that your abstract method raises an error.
@@ -0,0 +1 @@ | |||
|
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.
??
@@ -0,0 +1,106 @@ | |||
require_relative "test_helper.rb" | |||
|
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.
In this file you also need to have some negative-case tests with invalid arguments.
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions