Skip to content

Conversation

@Steph0088
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? Slack API had good documentation that allowed us to understand how to get and post data. We definitely continued to use postman and it really helped us conceptualize how data is organized and returned by API's.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? In the slack.rb file the user selects and option and it calls on a method within one of our classes that requests information from the Slack API. That information is returned in the method within the class method and printed for the user.
How does your program check for and handle errors when using the Slack API? We knew the names of our Channels and Users and so we used tests to ensure that it was correctly returning them.
Did you need to make any changes to the design work we did in class? If so, what were they? We generally used the same format and classes that were provided.
Did you use any of the inheritance idioms we've talked about in class? How? We did in our Recipient class where we used self.list, which is an abstract method that was implemented in the children classes.
How does VCR aid in testing a program that uses an API? It helps ensure you can still "call" on the slack api even when there is no connection to the API.

@tildeee
Copy link

tildeee commented Sep 21, 2019

slack.rb

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene (no slack tokens) x
Comprehension questions x
Functionality
List users/channels Yes, needs one small adjustment
Select user/channel x
Show details x
Send message
Program runs without crashing x
Implementation
API errors are handled appropriately Handled some user errors
Inheritance model matches in-class activity x
Inheritance idioms (abstract class, template methods, polymorphism) used appropriately x
Methods are used to break work down into simpler tasks x
Class and instance methods are used appropriately x
Tests written for User functionality x
Tests written for Channel Functionality x
Tests written for sending a message
Overall

Great work on this project, Farah and Steph! Your code is logical and clean, and your tests are well-constructed. You two did a great job getting the API functionality going and wrapping in tests, VCR, and design.

I have a few comments about the submission:

  • The tests look great, honestly! The tests are well-written and, overall, test details that are worth checking. Keep up this test-writing style!
  • The design that y'all went with did not use a Workspace class, but you all made it work by using class methods ✨, and you two used them correctly and well. Even though it doesn't look like some other projects, you two did a very smart way of still doing the same necessary functionality
  • Ultimately, this project is going to be marked as approaching standard because we didn't get to that sweet end of Wave 3
  • I'm adding just a few comments for suggestions on refactoring

Any other comment I have a minor one about handling API errors: we didn't go into handling API errors in depth during class, but I'd encourage you two to start thinking about: what happens if my response comes back with a status code that's not 200 OK? Your code currently doesn't handle that and would break in those cases! Food for thought.

Again good work on this overall!

@@ -0,0 +1,57 @@
.env
Copy link

Choose a reason for hiding this comment

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

we actually don't need a .gitignore file in the lib folder... just one in the project root directory!

def initialize(slack_id, name, topic, member_count)
super(slack_id, name)
@topic = topic
@member_count = member_count
Copy link

Choose a reason for hiding this comment

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

Do @topic or @member_count get used? Could we delete these?

super(slack_id, name)
@topic = topic
@member_count = member_count
@@channels_list << self
Copy link

Choose a reason for hiding this comment

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

I think that it's very clever to use the class variable @@channels_list and to shovel in self! However, does this variable ever get used beyond this? Do we need it?

@@channels_list << self
end

def self.list
Copy link

Choose a reason for hiding this comment

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

Nice helper method!

puts"Welcome to the Ada Slack CLI!"
puts"Select an option by number:"
options_array=["List Channels","List Users","Select User","Select Channel","Quit"]
options_array.each_with_index{ |channel, index|
Copy link

Choose a reason for hiding this comment

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

Nitpick: the syntax for this line means that every element in options_array when we iterate through it will be named channel... but options_array doesn't contain channels, it contains options! Would it make sense if this variable were named option instead of channel?


while user_answer != 5
if user_answer == 1
Channel.printed_channels_list
Copy link

Choose a reason for hiding this comment

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

Forgot to puts this!

end

puts "Select an option by number:"
options_array.each_with_index { |channel,index|
Copy link

Choose a reason for hiding this comment

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

Nitpick: same as above; instead of channel, is there a better variable name?

channels_array = Channel.printed_channels_list
channels_array.each do |channel|
if channel["name"] == "general"
assert (channel), "Expected true"
Copy link

Choose a reason for hiding this comment

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

To be honest, I'm just not sure what this line of code does-- what does it test?

end
end

it "should return an array of channels" do
Copy link

Choose a reason for hiding this comment

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

Looking at your implementation, the Channel.printed_channels_list method DOES NOT return an array of channels, and it returns an array of hashes! Your test name and test contents should reflect this

end

describe "self.select_channel_details method" do
it "should return true four 'general' details" do
Copy link

Choose a reason for hiding this comment

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

this is a great test! Good detail! Keep doing things like this when it's appropriate!

end
end

it "should return 'Not valid' statement if the Channel does not exist" do
Copy link

Choose a reason for hiding this comment

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

Good edge case test!

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