Skip to content

Instantly share code, notes, and snippets.

@shuuuuun
Created April 1, 2020 12:38
Show Gist options
  • Save shuuuuun/509633051b41e85c301578f452cc28bd to your computer and use it in GitHub Desktop.
Save shuuuuun/509633051b41e85c301578f452cc28bd to your computer and use it in GitHub Desktop.
slack通知テストしたときのメモ
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