Created
April 1, 2020 12:38
-
-
Save shuuuuun/509633051b41e85c301578f452cc28bd to your computer and use it in GitHub Desktop.
slack通知テストしたときのメモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'net/http' | |
module TestSlackNotifier | |
extend self | |
def send | |
uri = URI.parse('https://slack.com/api/chat.postMessage') | |
params = { | |
channel: '#channel_name', | |
icon_emoji: ':robot_face:', | |
username: 'bot', | |
token: ENV['SLACK_API_TOKEN'], | |
text: text, | |
} | |
Net::HTTP.post_form(uri, params) | |
end | |
def text | |
<<~EOS | |
_hogehoge_failure!_ | |
*Rails.env*: `#{Rails.env}` | |
*hoge*: `#{@hoge}` | |
*payload*: | |
``` | |
hogehoge | |
``` | |
EOS | |
end | |
end | |
# TestSlackNotifier.send |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment