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.
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.
This doesn't puts the details on the current recipient!
There was a problem hiding this comment.
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.
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.
Consider making these constant variables!
| end | ||
| end | ||
|
|
||
| def find_by_id_or_name(recipient_type, search_arg) |
| recipient_list = @users | ||
| else | ||
| recipient_list = @channels | ||
| end |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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 |
| 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 |
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.