Conversation
…_user: true to user.rb
…, all tests passing
| *.rbc | ||
| *.yml | ||
| /.config | ||
| /coverage/ |
| end | ||
|
|
||
| # method for send_message - just like in User.rb | ||
| def send_message(message) |
There was a problem hiding this comment.
You should raise an exception here if the post request is not successful. It is best practice to raise a custom exception such as APIError that inherits from StandardError.
| CHAT_URL = "https://slack.com/api/chat.postMessage" | ||
|
|
||
| module Slack | ||
| class Recipient |
There was a problem hiding this comment.
As you mention in your comprehension questions. You could make good use of inheritance by having User and Channel inherit from Recipient.
| end | ||
| end | ||
|
|
||
| it "raises an Argument for invalid selected user" do |
There was a problem hiding this comment.
Good test for a negative result. It would be good to define your own custom exception.
| # Send message test | ||
| describe "Send message" do | ||
| it "sends a message to selected recipient" do | ||
| VCR.use_cassette("send_message") do |
There was a problem hiding this comment.
Consider confirming that an exception is raised when a message is attempted to be sent to no recipient.
| query = { | ||
| token: ENV["SLACK_API_TOKEN"] | ||
| } | ||
| response = HTTParty.get(CHANNELS_LIST, query: query) |
There was a problem hiding this comment.
This is a key place where a parent class that has a self.get(url, params) method could help you make sure this functionality works the same in these 2 classes.
slack.rbWhat We're Looking For
|
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions