Skip to content

Conversation

@sophearychiv
Copy link

@sophearychiv sophearychiv commented Mar 22, 2019

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 explored Slack API during the lectures while following along with the instructor during live code sessions. We also used Postman to experiment with the query parameters. Also, we read the documentation on Slack's web pages. We learned using VCR to test the APIs, which is different from the regular tests.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? request/response cycle is the process of requesting the data from the client to the server. After receiving the requesting, the server processes the request and responds to the client. Our program requests the data from Slack APIs to make the lists of users and channels. Slack, then, process our requests and respond to our program with the info of the users and the channels. In regards to sending the message to the users or channels, our program sends POST requests to Slack which processes the requests and responds the messages back to the program.
How does your program check for and handle errors when using the Slack API? Our program uses custom errors to check and handle the errors by checking if the code status is not 200 OK or the response is not "ok".
Did you need to make any changes to the design work we did in class? If so, what were they? Yes, we did. We created parameters for most of the methods in workspace, so that the main method could be responsible for only printing the responses from user input. We also didn't implement the details method like the instructor's design.
Did you use any of the inheritance idioms we've talked about in class? How? We used an abstract class (Recipient) with template method self.list, for example.
How does VCR aid in testing a program that uses an API? It allows us to make a single call to the API and store the response so that when testing we don't have to continue to access the API and can instead access internal data. This makes testing faster and cheaper.

jessicacaley and others added 30 commits March 18, 2019 22:20
@CheezItMan
Copy link

slack.rb

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene (no slack tokens) Good number of commits and good commit messages, no api key in git!
Comprehension questions Check
Functionality
List users/channels Check
Select user/channel Check
Show details Check
Send message Check
Program runs without crashing Check
Implementation
API errors are handled appropriately Check
Inheritance model matches in-class activity Check
Inheritance idioms (abstract class, template methods, polymorphism) used appropriately Check, really nice work here
Methods are used to break work down into simpler tasks Check, nice work drying some of the methods like selecting a user/channel.
Class and instance methods are used appropriately Check
Overall Really well done, you definitely hit the learning goals here. Nice work. Look at my comments and let me know if you have questions.

@@ -0,0 +1,19 @@
require "dotenv"

Choose a reason for hiding this comment

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

This shouldn't be checked into git

@status_text = status_text
@status_emoji = status_emoji
end

Choose a reason for hiding this comment

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

No details method?

@topic = topic
@member_count = member_count
end

Choose a reason for hiding this comment

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

No details?

selected.send_message(message)
end

def tp_details_options

Choose a reason for hiding this comment

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

Instead of doing this in the Controller/Workspace, you could instead just return selected.details if you'd implemented that method in the User or Channel classes.

private

def select(input, recipients)
recipients.each do |recipient|

Choose a reason for hiding this comment

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

find would be a great option here.

@@ -0,0 +1,72 @@
require_relative "test_helper"
# THIS IS MY COMMENT - Jessica

Choose a reason for hiding this comment

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

And what a comment it is 😀

describe "send message" do
it "sends a valid message" do
VCR.use_cassette("slack_message") do
users = Slack::User.list

Choose a reason for hiding this comment

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

This seems to be testing User rather than recipient.

end
end

it "raises an error if api sends back not okay" do

Choose a reason for hiding this comment

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

You should test this with both an invalid token and again with an empty message.

end

def select_user(input)
select(input, users)

Choose a reason for hiding this comment

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

Really good work drying this up!

end

describe "send_message" do
it "sends a valid message" do

Choose a reason for hiding this comment

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

You should also test it with invalid messages.

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