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.
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.
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.
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.
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.
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.
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.detailsPresumably 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.
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