-
Notifications
You must be signed in to change notification settings - Fork 27
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
Ports - Angela and Shamira #3
base: master
Are you sure you want to change the base?
Conversation
slack.rbWhat We're Looking For
|
require "pry" | ||
Dotenv.load | ||
|
||
class 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.
This class is just one class method. Instead I suggest having a Channel
class with instance variables and methods. Your list
method could then return an array of Channel instances.
@@ -0,0 +1,62 @@ | |||
require "httparty" |
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.
Looks like you got started on this but didn't get finished. I suggest removing it from git.
|
||
#### TODO: CHANGE VARIABLE NAME | ||
practice = [] | ||
User.list.each do |user_name_list| |
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.
Here you end up making the same API call multiple times, this is inefficient. It might be much more useful to have list
create an array of User
instances with usernames, ids etc.
end | ||
end | ||
|
||
test_workspace = Workspace.new |
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.
Why do you create a Workspace in this Recipient
class.
end | ||
|
||
test_workspace = Workspace.new | ||
if channel_name.include?(user) |
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 if-elsif
block is a little awkward and could be made much cleaner with duck typing for the User
and Channel
classes.
class SlackApiError < StandardError; end | ||
|
||
def select_channel(selected) | ||
selected |
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 is the purpose of this method? It takes an argument and just returns the argument?
puts "4. Select Channel" | ||
puts "5. Quit" | ||
|
||
selection = gets.chomp |
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.
If this file isn't in your submission, please don't include it in the PR.
VCR.use_cassette("slack_channels") do | ||
Channel.new | ||
|
||
expect(Channel.list[0][0]).must_equal "everyone" |
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.
You can't always assume that the API will always return things in the same order. I would probably write the test to check to see if the array includes "everyone" instead.
end | ||
end | ||
|
||
it "will raise an error if given an empty message" 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.
👍
|
||
it "lists correct username" do | ||
VCR.use_cassette("slack_users") do | ||
User.new |
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.
Since you are using class methods you don't need to make an instance of User
.
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions