slack-ruby-bot 0.11.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.gitignore +3 -2
  4. data/.rubocop.yml +14 -1
  5. data/.rubocop_todo.yml +14 -42
  6. data/.travis.yml +11 -13
  7. data/CHANGELOG.md +39 -6
  8. data/CONTRIBUTING.md +5 -1
  9. data/DEPLOYMENT.md +63 -9
  10. data/Dangerfile +4 -0
  11. data/Gemfile +11 -7
  12. data/LICENSE.md +1 -1
  13. data/MIGRATION.md +13 -0
  14. data/README.md +133 -65
  15. data/Rakefile +2 -0
  16. data/TUTORIAL.md +23 -0
  17. data/UPGRADING.md +50 -0
  18. data/examples/inventory/Gemfile +2 -0
  19. data/examples/inventory/inventorybot.rb +5 -1
  20. data/examples/market/Gemfile +4 -3
  21. data/examples/market/marketbot.rb +22 -15
  22. data/examples/minimal/Gemfile +3 -1
  23. data/examples/minimal/pongbot.rb +2 -0
  24. data/examples/weather/Gemfile +2 -0
  25. data/examples/weather/weatherbot.rb +2 -0
  26. data/lib/config/application.rb +4 -2
  27. data/lib/config/boot.rb +2 -0
  28. data/lib/config/environment.rb +3 -1
  29. data/lib/slack-ruby-bot.rb +3 -1
  30. data/lib/slack-ruby-bot/about.rb +3 -1
  31. data/lib/slack-ruby-bot/app.rb +18 -12
  32. data/lib/slack-ruby-bot/bot.rb +3 -1
  33. data/lib/slack-ruby-bot/client.rb +25 -23
  34. data/lib/slack-ruby-bot/commands.rb +2 -0
  35. data/lib/slack-ruby-bot/commands/about.rb +3 -1
  36. data/lib/slack-ruby-bot/commands/base.rb +13 -21
  37. data/lib/slack-ruby-bot/commands/help.rb +10 -8
  38. data/lib/slack-ruby-bot/commands/hi.rb +3 -1
  39. data/lib/slack-ruby-bot/commands/support/attrs.rb +2 -0
  40. data/lib/slack-ruby-bot/commands/support/help.rb +4 -0
  41. data/lib/slack-ruby-bot/commands/support/match.rb +4 -3
  42. data/lib/slack-ruby-bot/commands/unknown.rb +3 -1
  43. data/lib/slack-ruby-bot/config.rb +7 -7
  44. data/lib/slack-ruby-bot/hooks.rb +2 -0
  45. data/lib/slack-ruby-bot/hooks/hello.rb +22 -3
  46. data/lib/slack-ruby-bot/hooks/hook_support.rb +2 -6
  47. data/lib/slack-ruby-bot/hooks/message.rb +11 -10
  48. data/lib/slack-ruby-bot/hooks/set.rb +3 -1
  49. data/lib/slack-ruby-bot/mvc.rb +2 -0
  50. data/lib/slack-ruby-bot/mvc/controller/base.rb +4 -3
  51. data/lib/slack-ruby-bot/mvc/model/base.rb +2 -0
  52. data/lib/slack-ruby-bot/mvc/mvc.rb +2 -0
  53. data/lib/slack-ruby-bot/mvc/view/base.rb +2 -0
  54. data/lib/slack-ruby-bot/rspec.rb +3 -1
  55. data/lib/slack-ruby-bot/rspec/support/bots_for_tests.rb +2 -0
  56. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/it_behaves_like_a_slack_bot.rb +4 -1
  57. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/not_respond.rb +3 -5
  58. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb +3 -7
  59. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb +15 -14
  60. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_messages.rb +26 -19
  61. data/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/start_typing.rb +32 -0
  62. data/lib/slack-ruby-bot/rspec/support/slack_api_key.rb +3 -1
  63. data/lib/slack-ruby-bot/rspec/support/slack_ruby_bot_configure.rb +2 -0
  64. data/lib/slack-ruby-bot/rspec/support/spec_helpers.rb +2 -0
  65. data/lib/slack-ruby-bot/server.rb +5 -28
  66. data/lib/slack-ruby-bot/support/loggable.rb +2 -0
  67. data/lib/slack-ruby-bot/version.rb +3 -1
  68. data/lib/slack_ruby_bot.rb +2 -0
  69. data/screenshots/create-classic-app.png +0 -0
  70. data/slack-ruby-bot.gemspec +6 -3
  71. data/spec/slack-ruby-bot/app_spec.rb +64 -1
  72. data/spec/slack-ruby-bot/client_spec.rb +103 -28
  73. data/spec/slack-ruby-bot/commands/about_spec.rb +2 -0
  74. data/spec/slack-ruby-bot/commands/aliases_spec.rb +2 -0
  75. data/spec/slack-ruby-bot/commands/attachment_spec.rb +2 -0
  76. data/spec/slack-ruby-bot/commands/bot_message_spec.rb +2 -0
  77. data/spec/slack-ruby-bot/commands/bot_messages_spec.rb +26 -0
  78. data/spec/slack-ruby-bot/commands/bot_spec.rb +2 -0
  79. data/spec/slack-ruby-bot/commands/commands_command_classes_spec.rb +2 -0
  80. data/spec/slack-ruby-bot/commands/commands_permitted_spec.rb +2 -0
  81. data/spec/slack-ruby-bot/commands/commands_precedence_spec.rb +2 -0
  82. data/spec/slack-ruby-bot/commands/commands_regexp_escape_spec.rb +2 -0
  83. data/spec/slack-ruby-bot/commands/commands_regexp_spec.rb +2 -0
  84. data/spec/slack-ruby-bot/commands/commands_spaces_spec.rb +2 -0
  85. data/spec/slack-ruby-bot/commands/commands_spec.rb +2 -0
  86. data/spec/slack-ruby-bot/commands/commands_with_block_spec.rb +2 -0
  87. data/spec/slack-ruby-bot/commands/commands_with_expression_spec.rb +2 -0
  88. data/spec/slack-ruby-bot/commands/direct_messages_spec.rb +2 -0
  89. data/spec/slack-ruby-bot/commands/empty_text_spec.rb +2 -0
  90. data/spec/slack-ruby-bot/commands/help_spec.rb +15 -13
  91. data/spec/slack-ruby-bot/commands/hi_spec.rb +2 -0
  92. data/spec/slack-ruby-bot/commands/match_spec.rb +2 -0
  93. data/spec/slack-ruby-bot/commands/message_loop_spec.rb +2 -0
  94. data/spec/slack-ruby-bot/commands/nil_message_spec.rb +2 -0
  95. data/spec/slack-ruby-bot/commands/non_breaking_space_spec.rb +29 -0
  96. data/spec/slack-ruby-bot/commands/not_implemented_spec.rb +2 -0
  97. data/spec/slack-ruby-bot/commands/operators_spec.rb +2 -0
  98. data/spec/slack-ruby-bot/commands/operators_with_block_spec.rb +2 -0
  99. data/spec/slack-ruby-bot/commands/scan_spec.rb +2 -0
  100. data/spec/slack-ruby-bot/commands/send_message_spec.rb +2 -0
  101. data/spec/slack-ruby-bot/commands/support/attrs_spec.rb +2 -0
  102. data/spec/slack-ruby-bot/commands/support/help_spec.rb +2 -0
  103. data/spec/slack-ruby-bot/commands/support/match_spec.rb +2 -0
  104. data/spec/slack-ruby-bot/commands/unknown_spec.rb +2 -0
  105. data/spec/slack-ruby-bot/config_spec.rb +2 -57
  106. data/spec/slack-ruby-bot/hooks/hello_spec.rb +51 -0
  107. data/spec/slack-ruby-bot/hooks/hook_support_spec.rb +2 -5
  108. data/spec/slack-ruby-bot/hooks/message_spec.rb +8 -35
  109. data/spec/slack-ruby-bot/hooks/set_spec.rb +2 -0
  110. data/spec/slack-ruby-bot/mvc/controller/controller_to_command_spec.rb +2 -0
  111. data/spec/slack-ruby-bot/rspec/respond_with_error_spec.rb +2 -0
  112. data/spec/slack-ruby-bot/rspec/respond_with_slack_message_spec.rb +20 -0
  113. data/spec/slack-ruby-bot/rspec/respond_with_slack_messages_spec.rb +36 -0
  114. data/spec/slack-ruby-bot/rspec/start_typing_spec.rb +36 -0
  115. data/spec/slack-ruby-bot/server_spec.rb +6 -33
  116. data/spec/slack-ruby-bot/support/loggable_spec.rb +2 -0
  117. data/spec/slack-ruby-bot/version_spec.rb +2 -0
  118. data/spec/spec_helper.rb +3 -6
  119. data/{lib/slack-ruby-bot/rspec → spec}/support/fixtures/slack/migration_in_progress.yml +0 -0
  120. data/{lib/slack-ruby-bot/rspec → spec}/support/vcr.rb +2 -0
  121. metadata +28 -29
  122. data/lib/initializers/giphy.rb +0 -8
  123. data/lib/initializers/giphy_client.rb +0 -39
  124. data/lib/slack-ruby-bot/rspec/support/fixtures/slack/giphy_burrito.yml +0 -69
  125. data/lib/slack-ruby-bot/rspec/support/fixtures/slack/giphy_client_burrito.yml +0 -71
  126. data/lib/slack-ruby-bot/rspec/support/fixtures/slack/giphy_client_burrito_rated_y.yml +0 -71
  127. data/screenshots/register-bot.png +0 -0
  128. data/spec/slack-ruby-bot/commands/send_gif_spec.rb +0 -25
  129. data/spec/slack-ruby-bot/commands/send_message_with_gif_spec.rb +0 -38
  130. data/spec/slack-ruby-bot/initializers/giphy_client_spec.rb +0 -28
  131. data/spec/slack-ruby-bot/initializers/giphy_spec.rb +0 -18
@@ -1,8 +0,0 @@
1
- begin
2
- require 'giphy'
3
- rescue LoadError
4
- else
5
- Giphy::Configuration.configure do |config|
6
- config.api_key = ENV['GIPHY_API_KEY']
7
- end
8
- end
@@ -1,39 +0,0 @@
1
- begin
2
- require 'GiphyClient'
3
-
4
- module Giphy
5
- module Config
6
- extend self
7
-
8
- attr_writer :api_key
9
- attr_writer :rating
10
-
11
- def api_key
12
- @api_key ||= ENV['GIPHY_API_KEY']
13
- end
14
-
15
- def rating
16
- @rating ||= 'G'
17
- end
18
- end
19
-
20
- class << self
21
- def configure
22
- block_given? ? yield(Config) : Config
23
- end
24
-
25
- def config
26
- Config
27
- end
28
-
29
- def client
30
- @client ||= GiphyClient::DefaultApi.new
31
- end
32
-
33
- def random(keywords)
34
- client.gifs_random_get(config.api_key, tag: keywords, rating: config.rating).data
35
- end
36
- end
37
- end
38
- rescue LoadError
39
- end
@@ -1,69 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://api.giphy.com/v1/gifs/random?api_key=giphy-api-key&tag=burrito
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.13.1
12
- Accept-Encoding:
13
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
- Accept:
15
- - "*/*"
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Content-Type:
22
- - application/json
23
- Server:
24
- - nginx
25
- X-Powered-By:
26
- - PHP/5.6.35-1+ubuntu14.04.1+deb.sury.org+1
27
- X-Robots-Tag:
28
- - noindex
29
- Access-Control-Allow-Credentials:
30
- - 'true'
31
- Access-Control-Allow-Methods:
32
- - GET, POST, PUT, DELETE, OPTIONS
33
- Access-Control-Allow-Headers:
34
- - Content-Type, Accept, x-requested-with, cache-control
35
- Access-Control-Allow-Origin:
36
- - "*"
37
- X-Kong-Upstream-Latency:
38
- - '178'
39
- X-Kong-Proxy-Latency:
40
- - '0'
41
- Accept-Ranges:
42
- - bytes
43
- Date:
44
- - Fri, 04 May 2018 12:16:32 GMT
45
- X-Served-By:
46
- - cache-den19624-DEN
47
- X-Cache:
48
- - MISS
49
- - MISS from 3
50
- X-Cache-Hits:
51
- - '0'
52
- X-Timer:
53
- - S1525436192.385028,VS0,VE231
54
- Vary:
55
- - Accept-Encoding
56
- Transfer-Encoding:
57
- - chunked
58
- Via:
59
- - kong/0.11.0.3-enterprise-edition, 1.1 varnish, 1.1 3 (squid)
60
- Connection:
61
- - keep-alive
62
- body:
63
- encoding: ASCII-8BIT
64
- string: '{"data":{"type":"gif","id":"xTiTndNDuNFxUW5Xoc","slug":"burrito-taco-bell-spicy-xTiTndNDuNFxUW5Xoc","url":"https:\/\/giphy.com\/gifs\/burrito-taco-bell-spicy-xTiTndNDuNFxUW5Xoc","bitly_gif_url":"https:\/\/gph.is\/1L7tIcH","bitly_url":"https:\/\/gph.is\/1L7tIcH","embed_url":"https:\/\/giphy.com\/embed\/xTiTndNDuNFxUW5Xoc","username":"","source":"https:\/\/www.youtube.com\/watch?v=o5eZS1epVYY","content_url":"","source_tld":"www.youtube.com","source_post_url":"https:\/\/www.youtube.com\/watch?v=o5eZS1epVYY","is_sticker":0,"import_datetime":"2015-05-15
65
- 17:32:24","trending_datetime":"1970-01-01 00:00:00","images":{"fixed_height_still":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200_s.gif","width":"274","height":"200"},"original_still":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy_s.gif","width":"477","height":"348"},"fixed_width":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200w.gif","width":"200","height":"146","size":"496043","mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200w.mp4","mp4_size":"52023","webp":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200w.webp","webp_size":"198114"},"fixed_height_small_still":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100_s.gif","width":"137","height":"100"},"fixed_height_downsampled":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200_d.gif","width":"274","height":"200","size":"201979","webp":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200_d.webp","webp_size":"72220"},"preview":{"width":"150","height":"108","mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy-preview.mp4","mp4_size":"38609"},"fixed_height_small":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100.gif","width":"137","height":"100","size":"274381","mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100.mp4","mp4_size":"31076","webp":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100.webp","webp_size":"121778"},"downsized_still":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy-downsized_s.gif","width":"477","height":"348","size":"81110"},"downsized":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy-downsized.gif","width":"477","height":"348","size":"1890849"},"downsized_large":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.gif","width":"477","height":"348","size":"1890849"},"fixed_width_small_still":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100w_s.gif","width":"100","height":"73"},"preview_webp":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy-preview.webp","width":"155","height":"113","size":"48796"},"fixed_width_still":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200w_s.gif","width":"200","height":"146"},"fixed_width_small":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100w.gif","width":"100","height":"73","size":"161406","mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100w.mp4","mp4_size":"21768","webp":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100w.webp","webp_size":"78562"},"downsized_small":{"width":"426","height":"312","mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy-downsized-small.mp4","mp4_size":"163378"},"fixed_width_downsampled":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200w_d.gif","width":"200","height":"146","size":"118889","webp":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200w_d.webp","webp_size":"46382"},"downsized_medium":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.gif","width":"477","height":"348","size":"1890849"},"original":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.gif","width":"477","height":"348","size":"1890849","frames":"26","mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.mp4","mp4_size":"163985","webp":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.webp","webp_size":"580074"},"fixed_height":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200.gif","width":"274","height":"200","size":"831881","mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200.mp4","mp4_size":"75652","webp":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200.webp","webp_size":"308056"},"looping":{"mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy-loop.mp4","mp4_size":"3398106"},"original_mp4":{"width":"480","height":"350","mp4":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.mp4","mp4_size":"163985"},"preview_gif":{"url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy-preview.gif","width":"97","height":"71","size":"47979"},"480w_still":{"url":"https:\/\/media0.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/480w_s.jpg","width":"480","height":"350"}},"title":"taco
66
- bell burrito GIF","image_original_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.gif","image_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.gif","image_mp4_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/giphy.mp4","image_frames":"26","image_width":"477","image_height":"348","fixed_height_downsampled_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200_d.gif","fixed_height_downsampled_width":"274","fixed_height_downsampled_height":"200","fixed_width_downsampled_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/200w_d.gif","fixed_width_downsampled_width":"200","fixed_width_downsampled_height":"146","fixed_height_small_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100.gif","fixed_height_small_still_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100_s.gif","fixed_height_small_width":"137","fixed_height_small_height":"100","fixed_width_small_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100w.gif","fixed_width_small_still_url":"https:\/\/media3.giphy.com\/media\/xTiTndNDuNFxUW5Xoc\/100w_s.gif","fixed_width_small_width":"100","fixed_width_small_height":"73","caption":""},"meta":{"status":200,"msg":"OK","response_id":"5aec4f204d68436e6bd7e384"}}'
67
- http_version:
68
- recorded_at: Fri, 04 May 2018 12:16:33 GMT
69
- recorded_with: VCR 3.0.3
@@ -1,71 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://api.giphy.com/v1/gifs/random?api_key=giphy-api-key&rating=G&tag=burrito
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Swagger-Codegen/1.0.0/ruby
12
- Content-Type:
13
- - application/json
14
- Accept:
15
- - application/json
16
- Expect:
17
- - ''
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Content-Type:
24
- - application/json
25
- Server:
26
- - nginx
27
- X-Powered-By:
28
- - PHP/5.6.35-1+ubuntu14.04.1+deb.sury.org+1
29
- X-Robots-Tag:
30
- - noindex
31
- Access-Control-Allow-Credentials:
32
- - 'true'
33
- Access-Control-Allow-Methods:
34
- - GET, POST, PUT, DELETE, OPTIONS
35
- Access-Control-Allow-Headers:
36
- - Content-Type, Accept, x-requested-with, cache-control
37
- Access-Control-Allow-Origin:
38
- - "*"
39
- X-Kong-Upstream-Latency:
40
- - '124'
41
- X-Kong-Proxy-Latency:
42
- - '0'
43
- Accept-Ranges:
44
- - bytes
45
- Date:
46
- - Fri, 04 May 2018 12:13:24 GMT
47
- X-Served-By:
48
- - cache-mdw17369-MDW
49
- X-Cache:
50
- - MISS
51
- - MISS from 3
52
- X-Cache-Hits:
53
- - '0'
54
- X-Timer:
55
- - S1525436004.038252,VS0,VE209
56
- Vary:
57
- - Accept-Encoding
58
- Transfer-Encoding:
59
- - chunked
60
- Via:
61
- - kong/0.11.0.3-enterprise-edition, 1.1 varnish, 1.1 3 (squid)
62
- Connection:
63
- - keep-alive
64
- body:
65
- encoding: UTF-8
66
- string: '{"data":{"type":"gif","id":"ImpBgQl7zzrO0","slug":"ImpBgQl7zzrO0","url":"https:\/\/giphy.com\/gifs\/ImpBgQl7zzrO0","bitly_gif_url":"https:\/\/gph.is\/28OFlbE","bitly_url":"https:\/\/gph.is\/28OFlbE","embed_url":"https:\/\/giphy.com\/embed\/ImpBgQl7zzrO0","username":"","source":"https:\/\/imgur.com\/gallery\/tYeJgmR","content_url":"","source_tld":"imgur.com","source_post_url":"https:\/\/imgur.com\/gallery\/tYeJgmR","is_sticker":0,"import_datetime":"2016-06-22
67
- 21:59:33","trending_datetime":"1970-01-01 00:00:00","images":{"fixed_height_still":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200_s.gif","width":"361","height":"200"},"original_still":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy_s.gif","width":"460","height":"255"},"fixed_width":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200w.gif","width":"200","height":"111","size":"286865","mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200w.mp4","mp4_size":"23159","webp":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200w.webp","webp_size":"116704"},"fixed_height_small_still":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100_s.gif","width":"180","height":"100"},"fixed_height_downsampled":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200_d.gif","width":"361","height":"200","size":"247115","webp":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200_d.webp","webp_size":"84834"},"preview":{"width":"286","height":"156","mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy-preview.mp4","mp4_size":"47310"},"fixed_height_small":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100.gif","width":"180","height":"100","size":"238718","mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100.mp4","mp4_size":"19988","webp":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100.webp","webp_size":"100746"},"downsized_still":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy-downsized_s.gif","width":"460","height":"255","size":"60015"},"downsized":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy-downsized.gif","width":"460","height":"255","size":"1325100"},"downsized_large":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.gif","width":"460","height":"255","size":"1325100"},"fixed_width_small_still":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100w_s.gif","width":"100","height":"55"},"preview_webp":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy-preview.webp","width":"193","height":"107","size":"48970"},"fixed_width_still":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200w_s.gif","width":"200","height":"111"},"fixed_width_small":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100w.gif","width":"100","height":"55","size":"79677","mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100w.mp4","mp4_size":"9285","webp":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100w.webp","webp_size":"41476"},"downsized_small":{"width":"460","height":"254","mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy-downsized-small.mp4","mp4_size":"129300"},"fixed_width_downsampled":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200w_d.gif","width":"200","height":"111","size":"81308","webp":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200w_d.webp","webp_size":"31548"},"downsized_medium":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.gif","width":"460","height":"255","size":"1325100"},"original":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.gif","width":"460","height":"255","size":"1325100","frames":"22","mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.mp4","mp4_size":"113680","webp":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.webp","webp_size":"538952"},"fixed_height":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200.gif","width":"361","height":"200","size":"893669","mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200.mp4","mp4_size":"59270","webp":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200.webp","webp_size":"315936"},"looping":{"mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy-loop.mp4","mp4_size":"1027642"},"original_mp4":{"width":"480","height":"266","mp4":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.mp4","mp4_size":"113680"},"preview_gif":{"url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy-preview.gif","width":"119","height":"66","size":"49996"},"480w_still":{"url":"https:\/\/media0.giphy.com\/media\/ImpBgQl7zzrO0\/480w_s.jpg","width":"480","height":"266"}},"title":"feel
68
- dollar GIF","image_original_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.gif","image_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.gif","image_mp4_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/giphy.mp4","image_frames":"22","image_width":"460","image_height":"255","fixed_height_downsampled_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200_d.gif","fixed_height_downsampled_width":"361","fixed_height_downsampled_height":"200","fixed_width_downsampled_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/200w_d.gif","fixed_width_downsampled_width":"200","fixed_width_downsampled_height":"111","fixed_height_small_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100.gif","fixed_height_small_still_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100_s.gif","fixed_height_small_width":"180","fixed_height_small_height":"100","fixed_width_small_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100w.gif","fixed_width_small_still_url":"https:\/\/media2.giphy.com\/media\/ImpBgQl7zzrO0\/100w_s.gif","fixed_width_small_width":"100","fixed_width_small_height":"55","caption":""},"meta":{"status":200,"msg":"OK","response_id":"5aec4e6466454764320d1ea2"}}'
69
- http_version:
70
- recorded_at: Fri, 04 May 2018 12:13:24 GMT
71
- recorded_with: VCR 3.0.3
@@ -1,71 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://api.giphy.com/v1/gifs/random?api_key=giphy-api-key&rating=Y&tag=burrito
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Swagger-Codegen/1.0.0/ruby
12
- Content-Type:
13
- - application/json
14
- Accept:
15
- - application/json
16
- Expect:
17
- - ''
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Content-Type:
24
- - application/json
25
- Accept-Ranges:
26
- - bytes
27
- - bytes
28
- Access-Control-Allow-Credentials:
29
- - 'true'
30
- Access-Control-Allow-Headers:
31
- - Content-Type, Accept, x-requested-with, cache-control
32
- Access-Control-Allow-Methods:
33
- - GET, POST, PUT, DELETE, OPTIONS
34
- Access-Control-Allow-Origin:
35
- - "*"
36
- Age:
37
- - '0'
38
- X-Robots-Tag:
39
- - noindex
40
- X-Kong-Upstream-Latency:
41
- - '150'
42
- X-Kong-Proxy-Latency:
43
- - '0'
44
- Content-Length:
45
- - '6419'
46
- Date:
47
- - Fri, 04 May 2018 12:22:29 GMT
48
- X-Served-By:
49
- - cache-den19627-DEN
50
- X-Cache:
51
- - MISS
52
- - MISS from 3
53
- X-Cache-Hits:
54
- - '0'
55
- X-Timer:
56
- - S1525436549.420736,VS0,VE202
57
- Vary:
58
- - Accept-Encoding, Accept-Encoding
59
- Via:
60
- - kong/0.11.0.3-enterprise-edition, 1.1 varnish, 1.1 3 (squid)
61
- Connection:
62
- - keep-alive
63
- body:
64
- encoding: UTF-8
65
- string: '{"data":{"type":"gif","id":"hkdKLmIgB3ane","slug":"cartoonhangover-cartoon-hangover-bee-and-puppycat-deckard-hkdKLmIgB3ane","url":"https:\/\/giphy.com\/gifs\/cartoonhangover-cartoon-hangover-bee-and-puppycat-deckard-hkdKLmIgB3ane","bitly_gif_url":"http:\/\/gph.is\/1qsLT19","bitly_url":"http:\/\/gph.is\/1qsLT19","embed_url":"https:\/\/giphy.com\/embed\/hkdKLmIgB3ane","username":"beeandpuppycat","source":"http:\/\/hangover.cartoonhangover.com\/post\/101982802617\/texts-from-bae-watch-now","content_url":"","source_tld":"hangover.cartoonhangover.com","source_post_url":"http:\/\/hangover.cartoonhangover.com\/post\/101982802617\/texts-from-bae-watch-now","is_sticker":0,"import_datetime":"2014-11-07
66
- 04:00:33","trending_datetime":"1970-01-01 00:00:00","user":{"avatar_url":"https:\/\/media.giphy.com\/avatars\/beeandpuppycat\/cyT9kR6MIqbK.gif","banner_url":"https:\/\/media.giphy.com\/headers\/beeandpuppycat\/TLNhReAxLFI9.jpg","profile_url":"https:\/\/giphy.com\/beeandpuppycat\/","username":"beeandpuppycat","display_name":"Bee
67
- and Puppycat","twitter":"","is_verified":true},"images":{"fixed_height_still":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200_s.gif","width":"356","height":"200"},"original_still":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy_s.gif","width":"400","height":"225"},"fixed_width":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200w.gif","width":"200","height":"113","size":"499059","mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200w.mp4","mp4_size":"159807","webp":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200w.webp","webp_size":"1023352"},"fixed_height_small_still":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100_s.gif","width":"178","height":"100"},"fixed_height_downsampled":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200_d.gif","width":"356","height":"200","size":"334553","webp":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200_d.webp","webp_size":"140458"},"preview":{"width":"400","height":"224","mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy-preview.mp4","mp4_size":"44780"},"fixed_height_small":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100.gif","width":"178","height":"100","size":"892868","mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100.mp4","mp4_size":"87596","webp":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100.webp","webp_size":"544088"},"downsized_still":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy-downsized_s.gif","width":"400","height":"225","size":"62328"},"downsized":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy-downsized.gif","width":"400","height":"225","size":"1002923"},"downsized_large":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.gif","width":"400","height":"225","size":"1002923"},"fixed_width_small_still":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100w_s.gif","width":"100","height":"56"},"preview_webp":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy-preview.webp","width":"174","height":"98","size":"48566"},"fixed_width_still":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200w_s.gif","width":"200","height":"113"},"fixed_width_small":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100w.gif","width":"100","height":"56","size":"499059","mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100w.mp4","mp4_size":"30578","webp":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100w.webp","webp_size":"226546"},"downsized_small":{"width":"400","height":"224","mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy-downsized-small.mp4","mp4_size":"44780"},"fixed_width_downsampled":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200w_d.gif","width":"200","height":"113","size":"132991","webp":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200w_d.webp","webp_size":"55952"},"downsized_medium":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.gif","width":"400","height":"225","size":"1002923"},"original":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.gif","width":"400","height":"225","size":"1002923","frames":"112","mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.mp4","mp4_size":"827796","webp":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.webp","webp_size":"1819838"},"fixed_height":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200.gif","width":"356","height":"200","size":"892868","mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200.mp4","mp4_size":"322931","webp":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200.webp","webp_size":"2597356"},"looping":{"mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy-loop.mp4","mp4_size":"3392324"},"original_mp4":{"width":"480","height":"270","mp4":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.mp4","mp4_size":"827796"},"preview_gif":{"url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy-preview.gif","width":"249","height":"140","size":"49584"},"480w_still":{"url":"hkdKLmIgB3ane\/480w_s.jpg","width":"480","height":"270"}},"title":"animation
68
- cartoon hangover GIF by Bee and Puppycat","image_original_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.gif","image_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.gif","image_mp4_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/giphy.mp4","image_frames":"112","image_width":"400","image_height":"225","fixed_height_downsampled_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200_d.gif","fixed_height_downsampled_width":"356","fixed_height_downsampled_height":"200","fixed_width_downsampled_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/200w_d.gif","fixed_width_downsampled_width":"200","fixed_width_downsampled_height":"113","fixed_height_small_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100.gif","fixed_height_small_still_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100_s.gif","fixed_height_small_width":"178","fixed_height_small_height":"100","fixed_width_small_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100w.gif","fixed_width_small_still_url":"https:\/\/media3.giphy.com\/media\/hkdKLmIgB3ane\/100w_s.gif","fixed_width_small_width":"100","fixed_width_small_height":"56","caption":""},"meta":{"status":200,"msg":"OK","response_id":"5aec508574684177590570c1"}}'
69
- http_version:
70
- recorded_at: Fri, 04 May 2018 12:22:30 GMT
71
- recorded_with: VCR 3.0.3
Binary file
@@ -1,25 +0,0 @@
1
- describe SlackRubyBot::Commands, if: WithGiphy.env? do
2
- let! :command do
3
- Class.new(SlackRubyBot::Commands::Base) do
4
- command 'send_gif_spec' do |client, data, _match|
5
- client.say(channel: data.channel, gif: 'dummy')
6
- end
7
- end
8
- end
9
-
10
- let(:gif_image_url) { 'http://media2.giphy.com/media/pzOijFsdDrsS4/giphy.gif' }
11
- let(:gif) { OpenStruct.new('image_url' => gif_image_url) }
12
-
13
- it 'sends a gif' do
14
- expect(Giphy).to receive(:random).and_return(gif)
15
- expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message(gif_image_url)
16
- end
17
- it 'eats up the error' do
18
- expect(Giphy).to receive(:random) { raise 'oh no!' }
19
- expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message('')
20
- end
21
- it 'eats up nil gif' do
22
- expect(Giphy).to receive(:random).and_return(nil)
23
- expect(message: "#{SlackRubyBot.config.user} send_gif_spec message").to respond_with_slack_message('')
24
- end
25
- end
@@ -1,38 +0,0 @@
1
- describe SlackRubyBot::Commands, if: WithGiphy.env? do
2
- let! :command do
3
- Class.new(SlackRubyBot::Commands::Base) do
4
- command 'send_message_with_gif_spec' do |client, data, match|
5
- client.say(channel: data.channel, text: match['expression'], gif: 'dummy')
6
- end
7
- end
8
- end
9
-
10
- let(:gif_image_url) { 'http://media2.giphy.com/media/pzOijFsdDrsS4/giphy.gif' }
11
- let(:gif) { OpenStruct.new('image_url' => gif_image_url) }
12
-
13
- it 'sends a message with gif' do
14
- expect(Giphy).to receive(:random).and_return(gif)
15
- expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message("message\n#{gif_image_url}")
16
- end
17
-
18
- it 'eats up errors' do
19
- expect(Giphy).to receive(:random) { raise 'oh no!' }
20
- expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message')
21
- end
22
-
23
- it 'eats up nil gif' do
24
- expect(Giphy).to receive(:random).and_return(nil)
25
- expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message')
26
- end
27
-
28
- context 'when client.send_gifs is false' do
29
- let :client do
30
- SlackRubyBot::Client.new.tap { |c| c.send_gifs = false }
31
- end
32
-
33
- it 'does not send a gif' do
34
- expect(Giphy).to_not receive(:random)
35
- expect(message: "#{SlackRubyBot.config.user} send_message_with_gif_spec message").to respond_with_slack_message('message')
36
- end
37
- end
38
- end
@@ -1,28 +0,0 @@
1
- if ENV.key?('WITH_GIPHY_CLIENT')
2
- describe Giphy do
3
- before do
4
- ENV['GIPHY_API_KEY'] = 'giphy-api-key'
5
- end
6
- after do
7
- ENV.delete('GIPHY_API_KEY')
8
- end
9
- context 'rated g' do
10
- let(:burrito_gif) { 'https://media2.giphy.com/media/ImpBgQl7zzrO0/giphy.gif' }
11
- it 'random', vcr: { cassette_name: 'giphy_client_burrito' } do
12
- expect(Giphy.random('burrito').image_url).to eq burrito_gif
13
- end
14
- end
15
- context 'rated y' do
16
- before do
17
- Giphy.config.rating = 'Y'
18
- end
19
- after do
20
- Giphy.config.rating = 'G'
21
- end
22
- let(:burrito_gif) { 'https://media3.giphy.com/media/hkdKLmIgB3ane/giphy.gif' }
23
- it 'random', vcr: { cassette_name: 'giphy_client_burrito_rated_y' } do
24
- expect(Giphy.random('burrito').image_url).to eq burrito_gif
25
- end
26
- end
27
- end
28
- end
@@ -1,18 +0,0 @@
1
- if ENV.key?('WITH_GIPHY')
2
- describe Giphy do
3
- let(:burrito_gif) { 'https://media3.giphy.com/media/xTiTndNDuNFxUW5Xoc/giphy.gif' }
4
- before do
5
- Giphy::Configuration.configure do |config|
6
- config.api_key = 'giphy-api-key'
7
- end
8
- end
9
- after do
10
- Giphy::Configuration.configure do |config|
11
- config.api_key = ENV['GIPHY_API_KEY']
12
- end
13
- end
14
- it 'random', vcr: { cassette_name: 'giphy_burrito' } do
15
- expect(Giphy.random('burrito').image_url.to_s).to eq burrito_gif
16
- end
17
- end
18
- end