-
Notifications
You must be signed in to change notification settings - Fork 26
Branches - Kelsey & Macaria #16
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
base: master
Are you sure you want to change the base?
Conversation
…wave 2 selection options
slack.rbWhat We're Looking For
Great work on this project, Kelsey and Macaria! The code is well-designed and well-written. It's great to see everything wrapped together so well-- great design, code style, tests, and implementation! Also, great work on the cat enhancement! My thoughts for improvement are these:
Any other comment I have a minor one that I've attached. One of them is 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 Overall, I think that the code and project submission are wonderful! I'd love to see a little more attention to detail in tests and user-output in the future, but otherwise you two did a great job on this project! |
| end | ||
|
|
||
| def self.load_all(url, token) | ||
| recipients = HTTParty.get(url, query: { token: token }) |
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 this get request gives back an error response? What would happen when we did recipients["channels"] in the next line?
| puts workspace.find_by_id_or_name("user", selection) | ||
| when "5" || "details" | ||
| puts "list_details_on_current_recipient" | ||
| workspace.list_details_on_current_recipient |
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 doesn't puts the details on the current recipient!
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.
Also, even if you add puts here, it just prints the recipient. There's a bug in your list_details_on_current_recipient method!
| @username = username | ||
| end | ||
|
|
||
| def self.load_all(url, token) |
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.
Seems like there isn't a test for this?
| @channel_url = "https://slack.com/api/conversations.list" | ||
| @user_url = "https://slack.com/api/users.list" | ||
| @message_url = "https://slack.com/api/chat.postMessage" | ||
| @channel_member_url = "https://slack.com/api/conversations.members" |
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.
Consider making these constant variables!
| end | ||
| end | ||
|
|
||
| def find_by_id_or_name(recipient_type, search_arg) |
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 method is great!
| recipient_list = @users | ||
| else | ||
| recipient_list = @channels | ||
| 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.
Possible refactor: Consider recipient_list = recipient_type.downcase == "user" ? @users : @channels -- your tests still pass!
| if @current_recipient == nil | ||
| raise ArgumentError, "No recipient is currently selected." | ||
| else | ||
| @current_recipient.load_details |
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 line evaluates into a string with some details, but it doesn't return anything meaningful overall; it doesn't puts anything either. In the end, this method just returns @current_recipient below
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 wish your tests checked on this behavior!
| "blocks" => cat_block, | ||
| }) | ||
| else | ||
| new_message = HTTParty.post(@message_url, |
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 this POST request comes back with an error response? That is not handled!
|
|
||
| def list_channels | ||
| channel_list = HTTParty.get(@channel_url, query: { token: TOKEN }) | ||
| channel_list["channels"].map do |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.
I'd like a more explicit return statement here so it's more readable!
| describe "load_details" do | ||
| it "returns an accurate username" do | ||
| expect @user.load_details.must_be_instance_of String | ||
| expect @user.load_details.must_include "ID:" |
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.
Because you know all of the details about the test data (what's in the VCR casettes), you could probably check that the string is exactly what you're looking for (in this case, the literal string "User Details\nID: UMURH3TBM\nName: Mackie Dove\nUsername: m.dove")
| end | ||
| it "gets details on a selected recipient" do | ||
| @workspace.find_by_id_or_name("channel", "CN85SCME3") | ||
| expect(@workspace.list_details_on_current_recipient).must_be_instance_of 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.
Is this actually what you want to do?
| it "can send a message with given text" do | ||
| expect @test_message["message"]["text"].must_equal "POTTYMOUTH" | ||
| end | ||
| it "allows for inclusion of a cat_block" 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.
Nice!
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions
superto call the idiomatic methods.