-
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
Sockets - Tati Hana #20
base: master
Are you sure you want to change the base?
Conversation
…tested in subclasses
slack.rbWhat We're Looking For
|
|
||
def self.list_url | ||
raise NotImplementedError, "TODO: implement me in a child class" | ||
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.
This is a great use of a template method.
# :nocov: | ||
def details | ||
raise NotImplementedError "TODO: implement me in a child class" | ||
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.
Instead of excluding this from coverage, why not have a test that Recipient
by itself without a subclass will raise this exception when this method is called?
workspace.send_message(message) | ||
# rescue SlackCli::SlackError | ||
puts "No user or channel selected, try again" | ||
# 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.
This error message always prints out, even if the send is successful. Instead, you should check the result and give the user positive or negative feedback.
def select_user(name) | ||
@selected = @users.find do |user| | ||
user.name == name || user.slack_id == name | ||
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.
Good use of the .find
enumerable here.
if @selected == nil | ||
puts "That user does not exist" | ||
else | ||
return @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.
Since this code is here to interact with the user, I would probably consider it view code and move it to the main
method.
describe "details" do | ||
it "lists details for an instance of Channel" do | ||
channel = channel_list[1] | ||
|
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 you create a Channel
manually with bogus data and then call .details
on it?
channel = SlackCli::Channel.new('bad_id', 'channel_dne', '', 0)
channel.details
Presumably this would work just fine, but it makes an interesting test case.
it "returns nil if no channel selected" do | ||
assert_nil(workspace.select_channel("")) | ||
assert_nil(workspace.select_channel(nil)) | ||
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.
I like that you're testing these failure cases. What happens to a previously selected user/channel in this case?
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions