diff --git a/lib/channel.rb b/lib/channel.rb new file mode 100644 index 00000000..7733dfa8 --- /dev/null +++ b/lib/channel.rb @@ -0,0 +1,31 @@ +# channel's name, topic, member count, and Slack ID + +class Channel < Recipient + attr_reader :topic, :member_count + + def initialize(slack_id, name, topic, member_count) + super(slack_id, name) + + @topic = topic + @member_count = member_count + end + + def self.list + url = "https://slack.com/api/channels.list" + query = {token: ENV['SLACK_TOKEN']} + + channels_list = [] + response = Recipient.get(url, query) + response["channels"].each do |channel| + new_channel = Channel.new(channel["id"], channel["name"], channel["topic"], channel["members"].length) + # binding.pry + channels_list << new_channel + end + return channels_list + end + + def details + return {slack_id: @slack_id, name: @name, topic: @topic, member_count: @member_count} + end + +end diff --git a/lib/recipient.rb b/lib/recipient.rb new file mode 100644 index 00000000..ce44b3f1 --- /dev/null +++ b/lib/recipient.rb @@ -0,0 +1,40 @@ +require "pry" +class SlackAPIError < StandardError ; end + +class Recipient + attr_reader :slack_id, :name + + def initialize(slack_id, name) + @slack_id = slack_id + @name = name + end + + def self.get(url, query) + response = HTTParty.get(url, query: query) + return response + end + + def details + raise NotImplementedError, 'Implement me in a child class!' + end + + def self.list + raise NotImplementedError, 'Implement me in a child class!' + end + + def send_message(message) + url = "https://slack.com/api/chat.postMessage" + body = {token: ENV['SLACK_TOKEN'], + text: message, + channel: @slack_id} + + message_post = HTTParty.post(url, body: body) + + unless message_post.code == 200 && message_post["ok"] + raise SlackAPIError.new("Error when posting #{message} to #{@slack_id}") + end + + return true + end + +end \ No newline at end of file diff --git a/lib/slack.rb b/lib/slack.rb index 960cf2f7..4729f337 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,10 +1,70 @@ #!/usr/bin/env ruby +require 'dotenv' +require 'httparty' +require 'table_print' + +require_relative 'recipient' +require_relative 'channel' +require_relative 'user' +require_relative 'workspace' + +# Tell dotenv to look for the .env file +Dotenv.load def main - puts "Welcome to the Ada Slack CLI!" + new_workspace = Workspace.new(User.list, Channel.list) + + while true + puts "Welcome to the Ada Slack CLI!" + puts "Select an option: list users, list channels, select user, select channel, details, send message to channel, send message to user or quit" + option = gets.chomp + + until option == "list users" || option == "list channels" || option == "quit" || option == "select user" || option == "select channel" || option == "details" || option == "send message to channel" || option == "send message to user" + puts "Select a valid option: list users, list channels, select user, select channel, details, send message or quit" + option = gets.chomp.downcase + end + + break if option == "quit" + + if option == "list users" + tp User.list + + elsif option == "list channels" + tp Channel.list + + elsif option == "select user" + puts "Enter the username or Slack ID" + selection = gets.chomp + new_workspace.select_user(selection) + + elsif option == "select channel" + puts "Enter the channel name or Slack ID" + selection = gets.chomp + new_workspace.select_channel(selection) - # TODO project + elsif option == "details" + if new_workspace.show_details == nil + puts "You haven't enter the name or Slack ID" + end + tp [new_workspace.show_details] + + elsif option == "send message to channel" + puts "Please enter the channel name or Slack ID" + selection = gets.chomp + channel = new_workspace.select_channel(selection) + puts "Please enter the message:" + message = gets.chomp + channel.send_message(message) + elsif option == "send message to user" + puts "Please enter the user name or Slack ID" + selection = gets.chomp + user = new_workspace.select_user(selection) + puts "Please enter the message:" + message = gets.chomp + user.send_message(message) + end + end puts "Thank you for using the Ada Slack CLI" end diff --git a/lib/user.rb b/lib/user.rb new file mode 100644 index 00000000..53559410 --- /dev/null +++ b/lib/user.rb @@ -0,0 +1,32 @@ +# username, real name, and Slack ID. +require "pry" +require 'dotenv' +Dotenv.load + + +class User < Recipient + attr_reader :real_name + + def initialize(slack_id, name, real_name) + super(slack_id, name) + @real_name = real_name + end + + def self.list + url = "https://slack.com/api/users.list" + query = {token: ENV['SLACK_TOKEN']} + + users_list = [] + response = Recipient.get(url, query) + response["members"].each do |member| + new_user = User.new(member["id"], member["name"], member["real_name"]) + users_list << new_user + end + return users_list + end + + def details + return {slack_id: @slack_id, name: @name, real_name: @real_name} + end + +end \ No newline at end of file diff --git a/lib/workspace.rb b/lib/workspace.rb new file mode 100644 index 00000000..29700bce --- /dev/null +++ b/lib/workspace.rb @@ -0,0 +1,52 @@ +require 'dotenv' +require "pry" +Dotenv.load + +class Workspace + attr_reader :users, :channels + attr_accessor :selected + def initialize(users, channels, selected: nil) + @users = users + @channels = channels + @selected = selected + end + + def select_channel(selection) + value = 0 + + Channel.list.each do |channel| + if channel.name == selection || channel.slack_id == selection + value = 1 + @selected = channel + return channel + end + end + + if value == 0 + raise ArgumentError.new("Please provide a valid selection for channel. ") + end + end + + def select_user(selection) + value = 0 + + User.list.each do |user| + if user.name == selection || user.slack_id == selection + value = 1 + @selected = user + return user + end + end + + if value == 0 + raise ArgumentError.new("Please provide a valid selection for user.") + end + end + + def show_details + if @selected == nil + return nil + end + return @selected.details + end +end \ No newline at end of file diff --git a/test/cassettes/channel.yml b/test/cassettes/channel.yml new file mode 100644 index 00000000..69f13f86 --- /dev/null +++ b/test/cassettes/channel.yml @@ -0,0 +1,163 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1181' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 21:07:09 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 1e290bb7-d0c0-4249-bb0b-1086998d49fc + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-3m6p + X-Cache: + - Miss from cloudfront + Via: + - 1.1 7022a5bbf9872d4a09d63e6cdb457dfe.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - Clb0oJNzNkMjcy3QRGPXwAbwwz-A-twfezv90ZFQogWj8Fu1FjEQQQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TMZTRGKCZ","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTGXDXD0","team_id":"TMZTRGKCZ","name":"dom_taylor","deleted":false,"color":"9f69e7","real_name":"dom_taylor","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"dom_taylor","real_name_normalized":"dom_taylor","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1639eaa6e83","image_24":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568073948},{"id":"UMUS3K402","team_id":"TMZTRGKCZ","name":"holmstedtk","deleted":false,"color":"3c989f","real_name":"Katie + Kennedy","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Katie + Kennedy","real_name_normalized":"Katie Kennedy","display_name":"Katie Kennedy","display_name_normalized":"Katie + Kennedy","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g4c6094fcae2","image_24":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568148491},{"id":"UMW5P9DHR","team_id":"TMZTRGKCZ","name":"nataliemtapias","deleted":false,"color":"e7392d","real_name":"Natalie + Tapias","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Natalie + Tapias","real_name_normalized":"Natalie Tapias","display_name":"Natalie Tapias","display_name_normalized":"Natalie + Tapias","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g84c1455fade","image_24":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568148346},{"id":"UN8GKRXK8","team_id":"TMZTRGKCZ","name":"cpgeorgina.sanchez","deleted":false,"color":"4bbe2e","real_name":"Georgina","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Georgina","real_name_normalized":"Georgina","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g23b757c8a5c","image_24":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568091134,"has_2fa":false}],"cache_ts":1568236029,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 21:07:09 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '721' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 22:36:55 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - c628fbc7-3051-4243-9fea-c1cc9cccf41a + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-ntnv + X-Cache: + - Miss from cloudfront + Via: + - 1.1 8ae6af4d17aae7471e5fe2792eb6abcd.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - W_M9STpmdZJ3u92fVDXXHJxMEak1IoBKW2FKOwoTMCI8I1Owqe-BEw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CN5S0B30U","name":"random","is_channel":true,"created":1568073948,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMTGXDXD0","last_set":1568073948},"purpose":{"value":"A + place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber + you''d prefer to keep out of more focused work-related channels.","creator":"UMTGXDXD0","last_set":1568073948},"previous_names":[],"num_members":4},{"id":"CN6A8MNHW","name":"general","is_channel":true,"created":1568073948,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMTGXDXD0","last_set":1568073948},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMTGXDXD0","last_set":1568073948},"previous_names":[],"num_members":4},{"id":"CN86A001M","name":"slack-cli","is_channel":true,"created":1568073949,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Really + fun topic for testing","creator":"UMW5P9DHR","last_set":1568150556},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":4},{"id":"CN9T10WBG","name":"pets","is_channel":true,"created":1568150583,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMW5P9DHR","name_normalized":"pets","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMW5P9DHR"],"topic":{"value":"for + pets and pet-friendly people","creator":"UMW5P9DHR","last_set":1568150610},"purpose":{"value":"collects + pets","creator":"UMW5P9DHR","last_set":1568150584},"previous_names":[],"num_members":2},{"id":"CNANHC6LF","name":"spaghetti","is_channel":true,"created":1568224227,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMW5P9DHR","name_normalized":"spaghetti","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 22:36:55 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/recipient.yml b/test/cassettes/recipient.yml new file mode 100644 index 00000000..24ae60c1 --- /dev/null +++ b/test/cassettes/recipient.yml @@ -0,0 +1,440 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '721' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 20:57:23 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - a8ec0837-e49e-4228-ad43-043d8aaaea9a + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-q42r + X-Cache: + - Miss from cloudfront + Via: + - 1.1 82ea95080f526df99896343fb7269b07.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - 8-_vQiRQzavf10WF7f06zyW9aO_AMAbRkQwx4a_hFVRDO1u79c9iMQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CN5S0B30U","name":"random","is_channel":true,"created":1568073948,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMTGXDXD0","last_set":1568073948},"purpose":{"value":"A + place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber + you''d prefer to keep out of more focused work-related channels.","creator":"UMTGXDXD0","last_set":1568073948},"previous_names":[],"num_members":4},{"id":"CN6A8MNHW","name":"general","is_channel":true,"created":1568073948,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMTGXDXD0","last_set":1568073948},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMTGXDXD0","last_set":1568073948},"previous_names":[],"num_members":4},{"id":"CN86A001M","name":"slack-cli","is_channel":true,"created":1568073949,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Really + fun topic for testing","creator":"UMW5P9DHR","last_set":1568150556},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":4},{"id":"CN9T10WBG","name":"pets","is_channel":true,"created":1568150583,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMW5P9DHR","name_normalized":"pets","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMW5P9DHR"],"topic":{"value":"for + pets and pet-friendly people","creator":"UMW5P9DHR","last_set":1568150610},"purpose":{"value":"collects + pets","creator":"UMW5P9DHR","last_set":1568150584},"previous_names":[],"num_members":2},{"id":"CNANHC6LF","name":"spaghetti","is_channel":true,"created":1568224227,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMW5P9DHR","name_normalized":"spaghetti","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 20:57:23 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=hello&channel=Dominique + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '60' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:45:54 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 53cdc5af-05c1-406d-9d9d-51cc10664feb + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-xtep + X-Cache: + - Miss from cloudfront + Via: + - 1.1 4db3f26ee4fd9a14a343fada3315105f.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - 6JxaubZ5TCd6eVVSPhOa0Qw10Gbme_xmCSCqR1Jrgu32-4FV6v2z5g== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:45:54 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=hello&channel=1232452 + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '60' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:46:49 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - aa15c413-577d-45f7-b845-9b0be86a1147 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-61a2 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 e8276e704fe9ab202d1f5aa2709d2f93.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - F_AW1THCmnNEcLMwjrjqzxjMJAI2NwtoSjn4lgoP4Wx_GCzKN0PWdQ== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:46:49 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=hello&channel=UMUS3K402 + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '171' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:19 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - e9c8655f-8adf-4915-8986-a3a16aa49a9d + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-g1op + X-Cache: + - Miss from cloudfront + Via: + - 1.1 a65ed239b1dc93560d93932663ec96bd.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - qdwb5sTEzMAOaTM0QZZacnEVaLUvNLtsoSNhi8_5uUH8yHEam05AXg== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channel":"DN9FGBEDV","ts":"1568411599.000100","message":{"type":"message","subtype":"bot_message","text":"hello","ts":"1568411599.000100","username":"Leaves + Georgina API Project","bot_id":"BN8SHMAC8"}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:19 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=hello&channel=UMTGXDXD0 + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '171' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:55:28 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 3b44b494-9051-4b96-a976-4feb81742207 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-x0x4 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 f90d3247f95b3d929916918b14de82bc.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - dWxDbuvrBsZq1P3YgYPtrbdUkenSiNQgvItbdt3KjHpeMsFh4RrwKA== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channel":"DN5S0B0KW","ts":"1568411728.000100","message":{"type":"message","subtype":"bot_message","text":"hello","ts":"1568411728.000100","username":"Leaves + Georgina API Project","bot_id":"BN8SHMAC8"}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:55:28 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=hello&channel=234245t56356 + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '60' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 22:01:22 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 938b4bea-41e7-4e83-b6df-11e99ddfbf24 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-vdna + X-Cache: + - Miss from cloudfront + Via: + - 1.1 cf334f8d204150d702090aa22e0fab56.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - fJ4HrgitPectW9Zg1dCu-LHEucDLXtt_H6ghtj0RMXwtna1gfCxYyA== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Fri, 13 Sep 2019 22:01:22 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/user.yml b/test/cassettes/user.yml new file mode 100644 index 00000000..5a38ea0d --- /dev/null +++ b/test/cassettes/user.yml @@ -0,0 +1,154 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1181' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 21:04:55 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - '09cf6a88-903a-4094-99ba-1bcfee34aa34' + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-3caj + X-Cache: + - Miss from cloudfront + Via: + - 1.1 331202b5b8aab67acbf389883133f257.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - CwPQv5MucQqETMlrzHiRLYV-92geJQE6olF1USgF3BrJKuQRokU-Zg== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TMZTRGKCZ","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTGXDXD0","team_id":"TMZTRGKCZ","name":"dom_taylor","deleted":false,"color":"9f69e7","real_name":"dom_taylor","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"dom_taylor","real_name_normalized":"dom_taylor","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1639eaa6e83","image_24":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568073948},{"id":"UMUS3K402","team_id":"TMZTRGKCZ","name":"holmstedtk","deleted":false,"color":"3c989f","real_name":"Katie + Kennedy","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Katie + Kennedy","real_name_normalized":"Katie Kennedy","display_name":"Katie Kennedy","display_name_normalized":"Katie + Kennedy","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g4c6094fcae2","image_24":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568148491},{"id":"UMW5P9DHR","team_id":"TMZTRGKCZ","name":"nataliemtapias","deleted":false,"color":"e7392d","real_name":"Natalie + Tapias","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Natalie + Tapias","real_name_normalized":"Natalie Tapias","display_name":"Natalie Tapias","display_name_normalized":"Natalie + Tapias","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g84c1455fade","image_24":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568148346},{"id":"UN8GKRXK8","team_id":"TMZTRGKCZ","name":"cpgeorgina.sanchez","deleted":false,"color":"4bbe2e","real_name":"Georgina","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Georgina","real_name_normalized":"Georgina","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g23b757c8a5c","image_24":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568091134,"has_2fa":false}],"cache_ts":1568235895,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 21:04:55 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=It%20works%21&channel=Ada-Cohort-12 + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '60' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:27:03 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 83f283c7-891d-4b92-8149-4753e86e9246 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-rg8i + X-Cache: + - Miss from cloudfront + Via: + - 1.1 0732be5515ffeda639cfe5f22fb04df6.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - b76xClcmMWDwijftgXyip97c6xDStcS5N9sOaSHCalsXSlrgFZ0NHQ== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:27:04 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml new file mode 100644 index 00000000..a527a8ec --- /dev/null +++ b/test/cassettes/workspace.yml @@ -0,0 +1,244 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1180' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 22:36:16 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 33bb5983-ca9a-43af-ad7c-06eb13485a3c + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-xcvc + X-Cache: + - Miss from cloudfront + Via: + - 1.1 34f8ef0e4c880df0650a814412a26ea6.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - 8sScCOJIEKCrqzaRsTdwjEoFL22ErlzyPn2V4UaDSAgoEtvbobb8Ow== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TMZTRGKCZ","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTGXDXD0","team_id":"TMZTRGKCZ","name":"dom_taylor","deleted":false,"color":"9f69e7","real_name":"dom_taylor","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"dom_taylor","real_name_normalized":"dom_taylor","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1639eaa6e83","image_24":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568073948},{"id":"UMUS3K402","team_id":"TMZTRGKCZ","name":"holmstedtk","deleted":false,"color":"3c989f","real_name":"Katie + Kennedy","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Katie + Kennedy","real_name_normalized":"Katie Kennedy","display_name":"Katie Kennedy","display_name_normalized":"Katie + Kennedy","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g4c6094fcae2","image_24":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568148491},{"id":"UMW5P9DHR","team_id":"TMZTRGKCZ","name":"nataliemtapias","deleted":false,"color":"e7392d","real_name":"Natalie + Tapias","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Natalie + Tapias","real_name_normalized":"Natalie Tapias","display_name":"Natalie Tapias","display_name_normalized":"Natalie + Tapias","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g84c1455fade","image_24":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568148346},{"id":"UN8GKRXK8","team_id":"TMZTRGKCZ","name":"cpgeorgina.sanchez","deleted":false,"color":"4bbe2e","real_name":"Georgina","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Georgina","real_name_normalized":"Georgina","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g23b757c8a5c","image_24":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568091134,"has_2fa":false}],"cache_ts":1568327777,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 22:36:17 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '828' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 22:36:17 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 9de0eba7-4ba8-4a7c-b5e6-f341a341fbc5 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-w4yr + X-Cache: + - Miss from cloudfront + Via: + - 1.1 174acb08636ac7d9e9a778bbf1bcbc53.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - 7IHp8yGL-qWDltCHIcxx_CWHq0X5EPaEVDXb0QL5o10shGA_j__Uig== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CN5S0B30U","name":"random","is_channel":true,"created":1568073948,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMTGXDXD0","last_set":1568073948},"purpose":{"value":"A + place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber + you''d prefer to keep out of more focused work-related channels.","creator":"UMTGXDXD0","last_set":1568073948},"previous_names":[],"num_members":4},{"id":"CN6A8MNHW","name":"general","is_channel":true,"created":1568073948,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMTGXDXD0","last_set":1568073948},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMTGXDXD0","last_set":1568073948},"previous_names":[],"num_members":4},{"id":"CN86A001M","name":"slack-cli","is_channel":true,"created":1568073949,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMTGXDXD0","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR","UN8GKRXK8"],"topic":{"value":"Really + fun topic for testing","creator":"UMW5P9DHR","last_set":1568150556},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":4},{"id":"CN9T10WBG","name":"pets","is_channel":true,"created":1568150583,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMW5P9DHR","name_normalized":"pets","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMW5P9DHR"],"topic":{"value":"for + pets and pet-friendly people","creator":"UMW5P9DHR","last_set":1568150610},"purpose":{"value":"collects + pets","creator":"UMW5P9DHR","last_set":1568150584},"previous_names":[],"num_members":2},{"id":"CNANHC6LF","name":"spaghetti","is_channel":true,"created":1568224227,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMW5P9DHR","name_normalized":"spaghetti","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UMTGXDXD0","UMUS3K402","UMW5P9DHR"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CNCQ49V7Y","name":"a-new-channel","is_channel":true,"created":1568320692,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMW5P9DHR","name_normalized":"a-new-channel","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":[],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":0},{"id":"CNCQ53EDC","name":"natalie-dinner-plans","is_channel":true,"created":1568320726,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMW5P9DHR","name_normalized":"natalie-dinner-plans","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UMW5P9DHR"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"what + is natalie eating for dinner","creator":"UMW5P9DHR","last_set":1568320727},"previous_names":[],"num_members":1}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 22:36:17 GMT +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1181' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:47:51 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - f9170734-0bb2-440b-b37c-adc6eb22855f + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-s1xo + X-Cache: + - Miss from cloudfront + Via: + - 1.1 3cd7af07832481c336aa1c93c9b4a6fe.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - ctEQR5IlmsoGYStHcbumJPuTgkfDXERGP-KvyaSOCupnoXtgCKsX6A== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TMZTRGKCZ","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTGXDXD0","team_id":"TMZTRGKCZ","name":"dom_taylor","deleted":false,"color":"9f69e7","real_name":"dom_taylor","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"dom_taylor","real_name_normalized":"dom_taylor","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1639eaa6e83","image_24":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1639eaa6e83ba43b00e58d5f77c257cb.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568073948},{"id":"UMUS3K402","team_id":"TMZTRGKCZ","name":"holmstedtk","deleted":false,"color":"3c989f","real_name":"Katie + Kennedy","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Katie + Kennedy","real_name_normalized":"Katie Kennedy","display_name":"Katie Kennedy","display_name_normalized":"Katie + Kennedy","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g4c6094fcae2","image_24":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/4c6094fcae2a494baccbd128ef25afd5.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568148491},{"id":"UMW5P9DHR","team_id":"TMZTRGKCZ","name":"nataliemtapias","deleted":false,"color":"e7392d","real_name":"Natalie + Tapias","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Natalie + Tapias","real_name_normalized":"Natalie Tapias","display_name":"Natalie Tapias","display_name_normalized":"Natalie + Tapias","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g84c1455fade","image_24":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/84c1455fadee76ee25d39ccb9670b4b4.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568148346},{"id":"UN8GKRXK8","team_id":"TMZTRGKCZ","name":"cpgeorgina.sanchez","deleted":false,"color":"4bbe2e","real_name":"Georgina","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Georgina","real_name_normalized":"Georgina","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g23b757c8a5c","image_24":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/23b757c8a5ce554904d7122dabceba36.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-512.png","status_text_canonical":"","team":"TMZTRGKCZ"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568091134,"has_2fa":false}],"cache_ts":1568332071,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:47:51 GMT +recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb new file mode 100644 index 00000000..b94efcb6 --- /dev/null +++ b/test/channel_test.rb @@ -0,0 +1,114 @@ +require_relative "test_helper" +require 'dotenv' +require 'httparty' + +Dotenv.load + +describe "Channel" do + before do + slack_id = "1232452" + name = "Random" + topic = "Ada" + member_count = "3" + + @channel = Channel.new(name, topic, member_count, slack_id) + end + + describe "Channel instantiation" do + it "creates an instance of Channel" do + expect(@channel).must_be_kind_of Channel + end + end + + describe "channel.get" do + it "gets response from server (JSON)" do + VCR.use_cassette("channel") do + #Arrange + url = "https://slack.com/api/channels.list" + query = {token: ENV['SLACK_TOKEN']} + #Act + response = User.get(url, query) + + #Assert + expect(response).must_be_instance_of HTTParty::Response + end + end + end + + + describe "self.list" do + it "returns a new channel's list" do + VCR.use_cassette("channel") do + #Act + list = Channel.list + #Assert + expect(list).must_be_kind_of Array + expect(list.length).must_equal 5 + end + end + + it "Returns accurate information about the first channel" do + VCR.use_cassette("channel") do + topic = { + "value" => "Non-work banter and water cooler conversation", + "creator" => "UMTGXDXD0", + "last_set" => 1568073948 + } + first = Channel.list.first + expect(first.slack_id).must_equal "CN5S0B30U" + expect(first.name).must_equal "random" + expect(first.topic).must_equal topic + expect(first.member_count).must_equal 4 + end + end + + it "Returns accurate information about the last channel" do + VCR.use_cassette("channel") do + topic = { + "value" => "", + "creator" => "", + "last_set" => 0 + } + last = Channel.list.last + expect(last.slack_id).must_equal "CNANHC6LF" + expect(last.name).must_equal "spaghetti" + expect(last.topic).must_equal topic + expect(last.member_count).must_equal 3 + end + end + end + + describe "details" do + it "returns a hash of details" do + VCR.use_cassette("channel") do + topic = { + "value" => "", + "creator" => "", + "last_set" => 0 + } + random = Channel.new("UN8GKRXK8", "Random", topic, 3) + expect(random.details).must_be_kind_of Hash + end + end + + it "returns accurate information" do + VCR.use_cassette("channel") do + topic = { + "value" => "", + "creator" => "", + "last_set" => 0 + } + random = Channel.new("UN8GKRXK8", "Random", topic, 3) + + result = random.details + expect(result[:slack_id]).must_equal "UN8GKRXK8" + expect(result[:name]).must_equal "Random" + expect(result[:topic]).must_equal topic + expect(result[:member_count]).must_equal 3 + end + end + end +end + + + \ No newline at end of file diff --git a/test/recipient_test.rb b/test/recipient_test.rb new file mode 100644 index 00000000..75cecb7e --- /dev/null +++ b/test/recipient_test.rb @@ -0,0 +1,55 @@ +require_relative "test_helper" +require 'dotenv' +require 'httparty' + +Dotenv.load + +describe "Recipient" do + before do + slack_id = "UMTGXDXD0" + name = "dom_taylor" + @recipient = Recipient.new(slack_id, name) + end + + describe "Recipient instantiation" do + it "is an instance of Recipient " do + expect(@recipient).must_be_kind_of Recipient + end + end + + describe "details" do + it "raises an error if invoked directly (without subclassing)" do + url = "https://slack.com/api/channels.list" + query = {token: 347358792354398} + + expect { + @recipient.details + }.must_raise NotImplementedError + end + end + + describe "self.list" do + it "raises an error if invoked directly (without subclassing)" do + + expect { + Recipient.list + }.must_raise NotImplementedError + end + end + + describe "send message" do + it "returns true if a message is sent" do + VCR.use_cassette("recipient") do + expect(@recipient.send_message("hello")).must_equal true + end + end + + it "raises an error when message isn't posted" do + new_recipient = Recipient.new("234245t56356", "fgererg") + + VCR.use_cassette("recipient") do + expect{new_recipient.send_message("hello")}.must_raise SlackAPIError + end + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 90aeb408..7a84c7a9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,9 +9,25 @@ require 'minitest/skip_dsl' require 'vcr' + Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new VCR.configure do |config| config.cassette_library_dir = "test/cassettes" config.hook_into :webmock + config.default_cassette_options = { + :record => :new_episodes, # record new data when we don't have it yet + :match_requests_on => [:method, :uri, :body], # The http method, URI and body of a request all need to match + } + # Don't leave our token lying around in a cassette file. + config.filter_sensitive_data("") do + ENV["SLACK_TOKEN"] + end end + + + +require_relative '../lib/recipient.rb' +require_relative '../lib/channel.rb' +require_relative '../lib/user.rb' +require_relative '../lib/workspace.rb' \ No newline at end of file diff --git a/test/user_test.rb b/test/user_test.rb new file mode 100644 index 00000000..963c2f3a --- /dev/null +++ b/test/user_test.rb @@ -0,0 +1,80 @@ +require_relative "test_helper" +require 'dotenv' +require 'httparty' + +Dotenv.load + +describe "User" do + before do + slack_id = "1232452" + name = "Dominique" + real_name = "Dominique Taylor" + @user = User.new(name, real_name, slack_id) + end + + describe "User instantiation" do + it "is an instance of User" do + expect(@user).must_be_kind_of User + end + end + + describe "self.list" do + it "returns a new user's list" do + VCR.use_cassette("user") do + #Act + list = User.list + #Assert + expect(list).must_be_kind_of Array + expect(list.length).must_equal 5 + end + end + + it "Returns accurate information about the first user" do + VCR.use_cassette("user") do + first = User.list.first + expect(first.slack_id).must_equal "USLACKBOT" + expect(first.real_name).must_equal "Slackbot" + expect(first.name).must_equal "slackbot" + end + end + + it "Returns accurate information about the last user" do + VCR.use_cassette("user") do + last = User.list.last + expect(last.slack_id).must_equal "UN8GKRXK8" + expect(last.real_name).must_equal "Georgina" + expect(last.name).must_equal "cpgeorgina.sanchez" + end + end + end + + describe "details" do + it "returns a hash of details" do + VCR.use_cassette("user") do + natalie = User.new("UN8GKRXK8", "Natalie Tapias", "natalie") + expect(natalie.details).must_be_kind_of Hash + end + end + + it "returns accurate information" do + VCR.use_cassette("user") do + natalie = User.new("UN8GKRXK8", "Natalie Tapias", "natalie") + result = natalie.details + expect(result[:slack_id]).must_equal "UN8GKRXK8" + expect(result[:real_name]).must_equal "natalie" + expect(result[:name]).must_equal "Natalie Tapias" + end + end + end + + # describe "send_message" do + # it "sends a message to the selected recipient" do + # VCR.use_cassette("user") do + # natalie = User.new("UN8GKRXK8", "Natalie Tapias", "natalie") + # expect(natalie.send_message("It works!", "Ada-Cohort-12")).must_equal true + # end + # end + # end + +end + diff --git a/test/workspace_test.rb b/test/workspace_test.rb new file mode 100644 index 00000000..c5f4be0f --- /dev/null +++ b/test/workspace_test.rb @@ -0,0 +1,102 @@ +require_relative "test_helper" +require 'dotenv' +require 'httparty' + +Dotenv.load + +describe "Workspace" do + before do + VCR.use_cassette("workspace") do + users = User.list + channels = Channel.list + selected = User.new("UN8GKRXK8", "Natalie Tapias", "natalie") + @workspace = Workspace.new(users, channels, selected: selected) + end + end + + describe "Workspace instantiation" do + it "is an instance of Workspace" do + expect(@workspace).must_be_kind_of Workspace + end + + it "gets the selected object from the select_user method" do + VCR.use_cassette("workspace") do + users = User.list + channels = Channel.list + workspace_1 = Workspace.new(users, channels) + workspace_1.select_user("UMUS3K402") + expect(workspace_1.selected).must_be_instance_of User + end + end + + end + + describe "select_channel" do + it "returns a selected channel instance" do + VCR.use_cassette("workspace") do + #Act + selected_channel = @workspace.select_channel("random") + + #Assert + expect(selected_channel).must_be_instance_of Channel + end + end + + it "raises an argument error for invalid selection" do + VCR.use_cassette("workspace") do + expect {(@workspace.select_channel("Pizza"))}.must_raise ArgumentError + end + end + end + + describe "select_user" do + it "returns a selected user instance" do + VCR.use_cassette("workspace") do + #Act + selected_user = @workspace.select_user("UMW5P9DHR") + + #Assert + expect(selected_user).must_be_instance_of User + end + end + + it "raises an argument error for invalid selection" do + VCR.use_cassette("workspace") do + expect {(@workspace.select_user("Pizza"))}.must_raise ArgumentError + end + end + + it "assigns selected object to selected instance variable" do + VCR.use_cassette("workspace") do + # selection = "random" + hello ="world" + hi ="world" + expect(hello).must_equal hi + @workspace.select_channel("random") + + topic = { + "value": "Non-work banter and water cooler conversation", + "creator": "UMTGXDXD0", + "last_set": 1568073948 + } + result = Channel.new("CN5S0B30U", "random", topic, 4) + + expect(@workspace.selected).must_be_instance_of Channel + end + end + end + + describe "show_details" do + it "show the details of the selected user or channel" do + VCR.use_cassette("workspace") do + expect(@workspace.show_details).must_be_kind_of Hash + end + end + + it "returns accurate details" do + VCR.use_cassette("workspace") do + expect(@workspace.show_details[:slack_id]).must_equal "UN8GKRXK8" + end + end + end +end \ No newline at end of file