Leaves - Mariya Burrows & Morgan Schuler#21
Conversation
… working on methods for list vs. details & how that interacts with slack.rb
slack.rbWhat We're Looking For
|
| @@ -13,6 +13,8 @@ | |||
| # Used by dotenv library to load environment variables. | |||
| # .env | |||
There was a problem hiding this comment.
You should uncomment this line to include it in your .gitignore file.
|
|
||
| channel_details["slack_id"] = self.slack_id | ||
| channel_details["name"] = self.name | ||
| channel_details["topic"] = self.topic |
There was a problem hiding this comment.
the "topic" key provides this hash: {"value"=>"Non-work banter and water cooler conversation", "creator"=>"UMZNG8T8R", "last_set"=>1568061999} It seems that you just want "value" in this case.
| end | ||
|
|
||
| def self.get(url, params) | ||
| return HTTParty.get(url, query: params) |
There was a problem hiding this comment.
What is this isn't a success? Make sure you are prepared for something to go wrong and raise a SlackAPIError.
| ["List users", "List channels", "Quit"] | ||
| ) | ||
|
|
||
| # path for list users |
There was a problem hiding this comment.
Consider using case/when for this control structure.
| ) | ||
|
|
||
| # user decides how they want to look up recipient | ||
| if search_choice == "1" |
There was a problem hiding this comment.
With these nested conditionals, make sure that users always have the option to quit.
| @selected = nil | ||
| end | ||
|
|
||
| def select_user_slack_id(slack_id: nil) |
There was a problem hiding this comment.
The following 4 methods are all quite similar. Is there a way to DRY up this code?
| end | ||
|
|
||
| puts "Thank you for using the Ada Slack CLI" | ||
| def print_user_list(list) |
There was a problem hiding this comment.
print_user_list and print_channel_list are quite similar. Is there a way to dry up this code?
| end | ||
| end | ||
|
|
||
| it "selects user by slack_id" do |
There was a problem hiding this comment.
What if the recipient you try to select doesn't exist? What happens to a previously selected user if you try to select a bad user? Remember you always need to test for positive and negative results.
| @workspace.select_channel_slack_id(slack_id: "HASFHAS") | ||
| end | ||
|
|
||
| expect{ |
There was a problem hiding this comment.
It is not clear from the name of this test why this raises a standard error.
| expect(@channel.details).must_be_kind_of Hash | ||
| end | ||
|
|
||
| it "has a slack_id" do |
There was a problem hiding this comment.
Include tests for the other details.
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions