-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fire - Alice & Madeline #25
base: master
Are you sure you want to change the base?
Conversation
SORRY FOR WRITING THIS HERE, WE SUBMITED WITHOUT ANSWERING THE QUESTIONS, SO WE WILL ANSWER THEM RIGHT HERE:
|
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.
Slack CLI
Major Learning Goals/Code Review
Criteria | yes/no, and optionally any details/lines of code to reference |
---|---|
Practices best practices working with APIs. The .env is not checked into git, and no API token was directly used in the Ruby code without ENV . |
✔️ |
Practices error handling with APIs. For all pieces of code that make an API call, it handles API requests that come back with errors/error status codes appropriately. | ✔️ |
Implements inheritance and inheritance idioms. There is a Recipient class. User and Channel inherit from Recipient . In Recipient , there are appropriate methods defined that are used in both User and Channel . Some may be implemented. Some may be template methods. |
|
Practices clean code. lib/slack.rb only interacts with Workspace to show a separation of responsibilities. Complex logic is broken into smaller helper methods. |
|
Practices instance methods vs. class methods appropriately. The methods to list all Channels or Users is likely a class method within those respective classes. | ✔️, However like I noted inline your methods to list users and channels would make an excellent factory method (class method). |
Practices best practices for testing. The project has and uses VCR mocking when running tests, and can run offline. | ✔️ |
Practices writing tests. The User , Channel , and Workspace classes have unit tests. |
|
Practices writing tests. There are tests for sending messages (the location of these tests may differ, but is likely in Recipient ) |
|
Practices git with at least 15 small commits and meaningful commit messages |
Functional Requirements
Functional Requirement | yes/no |
---|---|
As a user of the CLI program, I can list users and channels | ✔️? |
As a user of the CLI program, I can select users and channels | ✔️? |
As a user of the CLI program, I can show the details of a selected user or channel | ✔️? |
As a user of the CLI program, when I input something inappropriately, the program runs without crashing | ✔️? |
Overall Feedback
Overall Feedback | Criteria | yes/no |
---|---|---|
Yellow (Approaches Standards) | 6+ in Code Review && 2+ in Functional Requirements |
Code Style Bonus Awards
Was the code particularly impressive in code style for any of these reasons (or more...?)
Quality | Yes? |
---|---|
Perfect Indentation | ✅ |
Descriptive/Readable | ✅ |
Concise | ✅ |
Summary
Your design has some duplication of functionality, you do make some unnecesary API calls and your testing is minimal at best. That said it works and hits most of the learning goals here.
Also you didn't answer the comprehension questions.
def get_users | ||
user_response = HTTParty.get(GET_USER_PATH, query: { token: ENV["SLACK_TOKEN"] }) | ||
|
||
@users = user_response["members"].map do |member| | ||
User.new(member["name"], member["real_name"], member["id"]) | ||
end | ||
|
||
unless user_response.code == 200 | ||
raise SlackApiError, "Error: #{user_response.parsed_response["error"]}" | ||
end | ||
|
||
return @users | ||
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.
I just want to point out that listing users is a lot like listing channels. You could abstract this content out into a parent class.
You could also create a factory method in your classes like we did in Ride Share or Grocery Store.
def select_user(username_or_id) | ||
selected_user = self.get_users | ||
.select { |user| user.username == username_or_id || user.id == username_or_id } | ||
.first | ||
return selected_user | ||
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.
This makes an api call every time you select a user, why not instead use your instance variable @users
if it's not empty.
def select_channel(name_or_id) | ||
selected_channel = self.get_channels | ||
.select { |channel| channel.name == name_or_id || channel.id == name_or_id } | ||
.first | ||
return selected_channel | ||
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.
Just note how similar this is to select_user
could you absract this into a helper method?
@@ -0,0 +1,13 @@ | |||
class User |
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.
Just noting the User and Channel classes are pretty small, you could make the method to retrieve all the users a method here inside User (class method), similar to how we did Ride share.
end | ||
end | ||
|
||
it "returns \"Message sent!\" when message is sent" 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.
What happens if you send a message with no channel or user selected?
require_relative "test_helper" | ||
require_relative "../lib/workspace" | ||
|
||
describe "Workspace" 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 suggest using some sub-describes for the functionality here. Like one for each method allowing you to group tests a bit.
end | ||
end | ||
|
||
it "select channel" 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.
What about selecting a channel that doesn't exist?
expect(@workspace.send_message(recipient_id, message)).must_be_same_as true | ||
end | ||
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.
No tests for users or channels?
Assignment Submission: Slack CLI
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection