Skip to content

Conversation

@YasminM11
Copy link

slack.rb

Congratulations! You're submitting your assignment!

You and your partner should collaborate on the answers to these questions.

Comprehension Questions

Question Answer
How did you go about exploring the Slack API? Did you learn anything that would be useful for your next project involving an API? We reviewed Slack's API documentation and we used Postman to send requests. We learned all APIs are unique.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? Request Response Cycle: how the user and program interact to receive a request and output a response. Our program is receiving input from the user to send a message and then communicating with Slack's API to send the message to the specified channel/user.
How does your program check for and handle errors when using the Slack API? For example: we raise an error when the user tries to send a message to an unidentified user.
Did you need to make any changes to the design work we did in class? If so, what were they? We did not end up using Recipient or Workspace, which were included in our original design.
Did you use any of the inheritance idioms we've talked about in class? How? We did not - but in refactoring, we could have changed is making Recipient the super and having methods inherit from it.
How does VCR aid in testing a program that uses an API? Using VCR records the test data once its run, to decrease the need for submitting new API calls for tests. Decreases expense of multiple calls and ability to work repetitive tests offline.

*.rbc
*.yml
/.config
/coverage/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be coverage/

end

# method for send_message - just like in User.rb
def send_message(message)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should raise an exception here if the post request is not successful. It is best practice to raise a custom exception such as APIError that inherits from StandardError.

CHAT_URL = "https://slack.com/api/chat.postMessage"

module Slack
class Recipient

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you mention in your comprehension questions. You could make good use of inheritance by having User and Channel inherit from Recipient.

end
end

it "raises an Argument for invalid selected user" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test for a negative result. It would be good to define your own custom exception.

# Send message test
describe "Send message" do
it "sends a message to selected recipient" do
VCR.use_cassette("send_message") do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider confirming that an exception is raised when a message is attempted to be sent to no recipient.

query = {
token: ENV["SLACK_API_TOKEN"]
}
response = HTTParty.get(CHANNELS_LIST, query: query)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a key place where a parent class that has a self.get(url, params) method could help you make sure this functionality works the same in these 2 classes.

@beccaelenzil
Copy link

beccaelenzil commented Sep 18, 2019

slack.rb

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene (no slack tokens) check
Comprehension questions 2. provide the steps for the request/response cycle
Functionality
List users/channels check
Select user/channel check
Show details check
Send message send message to user not implemented (per our discussion)
Program runs without crashing check
Implementation
API errors are handled appropriately While we don't have the tools yet to test a bad get request in this instance, it is good to think about and build in functionality to deal with bad requests.
Inheritance model matches in-class activity I see you went your own direction. Given that you do not have a workspace class, it was a good choice to make list_users, list_channels, select_user, and select_channel class methods.
Inheritance idioms (abstract class, template methods, polymorphism) used appropriately This was a key learning goal for this project -- inheritance allows you to reduce the amount of code you write and also reduce the amount of testing. If functionality works for the parent class, you can trust it works for the child class.
Methods are used to break work down into simpler tasks check
Class and instance methods are used appropriately check
Tests written for User functionality check
Tests written for Channel Functionality check
Tests written for sending a message check
Overall Good work meeting the requirements of the Slack CLI. You did a great job writing the user interface and dealing with valid and invalid user input appropriately. It provides a nice user experience. Given that you decided not to use the recommended class structure, the functionality is well implemented. I would like to see you make use of inheritance and template methods to gain fluency with them. Furthermore, it is important to make sure you thoroughly test your code including positive and negative nominal and edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants