From b5228f465347bbdd6eba14feaedd94e9a22f68d6 Mon Sep 17 00:00:00 2001 From: dblock Date: Sat, 28 Mar 2020 18:31:20 -0400 Subject: [PATCH] Upgraded RuboCop to 0.80.1, targeting Ruby 2.3+. --- .rubocop.yml | 16 +++++- .rubocop_todo.yml | 49 +++++-------------- .travis.yml | 12 +++-- CHANGELOG.md | 3 +- Dangerfile | 2 + Gemfile | 4 +- LICENSE.md | 2 +- README.md | 2 +- Rakefile | 2 + UPGRADING.md | 8 +++ examples/inventory/Gemfile | 2 + examples/inventory/inventorybot.rb | 6 ++- examples/market/Gemfile | 2 + examples/market/marketbot.rb | 2 + examples/minimal/Gemfile | 2 + examples/minimal/pongbot.rb | 2 + examples/weather/Gemfile | 2 + examples/weather/weatherbot.rb | 2 + lib/config/application.rb | 6 ++- lib/config/boot.rb | 2 + lib/config/environment.rb | 4 +- lib/initializers/giphy.rb | 2 + lib/initializers/giphy_client.rb | 2 + lib/slack-ruby-bot.rb | 4 +- lib/slack-ruby-bot/about.rb | 4 +- lib/slack-ruby-bot/app.rb | 2 + lib/slack-ruby-bot/bot.rb | 2 + lib/slack-ruby-bot/client.rb | 11 +++-- lib/slack-ruby-bot/commands.rb | 2 + lib/slack-ruby-bot/commands/about.rb | 2 + lib/slack-ruby-bot/commands/base.rb | 13 ++++- lib/slack-ruby-bot/commands/help.rb | 16 +++--- lib/slack-ruby-bot/commands/hi.rb | 2 + lib/slack-ruby-bot/commands/support/attrs.rb | 2 + lib/slack-ruby-bot/commands/support/help.rb | 4 ++ lib/slack-ruby-bot/commands/support/match.rb | 7 +-- lib/slack-ruby-bot/commands/unknown.rb | 2 + lib/slack-ruby-bot/config.rb | 3 ++ lib/slack-ruby-bot/hooks.rb | 2 + lib/slack-ruby-bot/hooks/hello.rb | 5 +- lib/slack-ruby-bot/hooks/hook_support.rb | 2 + lib/slack-ruby-bot/hooks/message.rb | 7 ++- lib/slack-ruby-bot/hooks/set.rb | 4 +- lib/slack-ruby-bot/mvc.rb | 2 + lib/slack-ruby-bot/mvc/controller/base.rb | 7 +-- lib/slack-ruby-bot/mvc/model/base.rb | 2 + lib/slack-ruby-bot/mvc/mvc.rb | 2 + lib/slack-ruby-bot/mvc/view/base.rb | 2 + lib/slack-ruby-bot/rspec.rb | 4 +- .../rspec/support/bots_for_tests.rb | 2 + .../it_behaves_like_a_slack_bot.rb | 2 + .../support/slack-ruby-bot/not_respond.rb | 2 + .../slack-ruby-bot/respond_with_error.rb | 2 + .../respond_with_slack_message.rb | 4 +- .../respond_with_slack_messages.rb | 6 ++- .../support/slack-ruby-bot/start_typing.rb | 6 ++- .../rspec/support/slack_api_key.rb | 2 + .../rspec/support/slack_ruby_bot_configure.rb | 2 + .../rspec/support/spec_helpers.rb | 2 + lib/slack-ruby-bot/rspec/support/vcr.rb | 2 + lib/slack-ruby-bot/server.rb | 2 + lib/slack-ruby-bot/support/loggable.rb | 2 + lib/slack-ruby-bot/version.rb | 4 +- lib/slack_ruby_bot.rb | 2 + slack-ruby-bot.gemspec | 6 ++- spec/slack-ruby-bot/app_spec.rb | 2 + spec/slack-ruby-bot/client_spec.rb | 2 + spec/slack-ruby-bot/commands/about_spec.rb | 2 + spec/slack-ruby-bot/commands/aliases_spec.rb | 2 + .../commands/attachment_spec.rb | 2 + .../commands/bot_message_spec.rb | 2 + spec/slack-ruby-bot/commands/bot_spec.rb | 2 + .../commands/commands_command_classes_spec.rb | 2 + .../commands/commands_permitted_spec.rb | 2 + .../commands/commands_precedence_spec.rb | 2 + .../commands/commands_regexp_escape_spec.rb | 2 + .../commands/commands_regexp_spec.rb | 2 + .../commands/commands_spaces_spec.rb | 2 + spec/slack-ruby-bot/commands/commands_spec.rb | 2 + .../commands/commands_with_block_spec.rb | 2 + .../commands/commands_with_expression_spec.rb | 2 + .../commands/direct_messages_spec.rb | 2 + .../commands/empty_text_spec.rb | 2 + spec/slack-ruby-bot/commands/help_spec.rb | 28 ++++++----- spec/slack-ruby-bot/commands/hi_spec.rb | 2 + spec/slack-ruby-bot/commands/match_spec.rb | 2 + .../commands/message_loop_spec.rb | 2 + .../commands/nil_message_spec.rb | 2 + .../commands/not_implemented_spec.rb | 2 + .../slack-ruby-bot/commands/operators_spec.rb | 2 + .../commands/operators_with_block_spec.rb | 2 + spec/slack-ruby-bot/commands/scan_spec.rb | 2 + spec/slack-ruby-bot/commands/send_gif_spec.rb | 2 + .../commands/send_message_spec.rb | 2 + .../commands/send_message_with_gif_spec.rb | 2 + .../commands/support/attrs_spec.rb | 2 + .../commands/support/help_spec.rb | 2 + .../commands/support/match_spec.rb | 2 + spec/slack-ruby-bot/commands/unknown_spec.rb | 2 + spec/slack-ruby-bot/config_spec.rb | 2 + spec/slack-ruby-bot/hooks/hello_spec.rb | 2 + .../slack-ruby-bot/hooks/hook_support_spec.rb | 2 + spec/slack-ruby-bot/hooks/message_spec.rb | 4 +- spec/slack-ruby-bot/hooks/set_spec.rb | 2 + .../initializers/giphy_client_spec.rb | 2 + .../slack-ruby-bot/initializers/giphy_spec.rb | 2 + .../controller/controller_to_command_spec.rb | 2 + .../rspec/respond_with_error_spec.rb | 2 + .../rspec/respond_with_slack_message_spec.rb | 2 + .../rspec/respond_with_slack_messages_spec.rb | 2 + .../slack-ruby-bot/rspec/start_typing_spec.rb | 2 + spec/slack-ruby-bot/server_spec.rb | 2 + spec/slack-ruby-bot/support/loggable_spec.rb | 2 + spec/slack-ruby-bot/version_spec.rb | 2 + spec/spec_helper.rb | 2 + 115 files changed, 328 insertions(+), 99 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 783b25f..57c098a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.2.0 + TargetRubyVersion: 2.3 Exclude: - vendor/**/* - examples/**/vendor/**/* @@ -8,10 +8,22 @@ AllCops: Metrics: Enabled: false -Metrics/LineLength: +Layout/LineLength: Max: 512 Style/Documentation: Enabled: false +Style/HashEachMethods: + Enabled: true + +Style/HashTransformKeys: + Enabled: true + +Style/HashTransformValues: + Enabled: true + +Style/ModuleFunction: + Enabled: false + inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a7b33a4..d062067 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,36 +1,29 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-03-25 10:27:43 -0400 using RuboCop version 0.58.2. +# on 2020-03-28 18:37:09 -0400 using RuboCop version 0.80.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent -Layout/IndentHeredoc: - Exclude: - - 'lib/slack-ruby-bot/commands/help.rb' - - 'spec/slack-ruby-bot/commands/help_spec.rb' - # Offense count: 1 Lint/DuplicateMethods: Exclude: - 'lib/slack-ruby-bot/hooks/set.rb' # Offense count: 2 -Lint/HandleExceptions: +# Configuration parameters: AllowComments. +Lint/SuppressedException: Exclude: - 'lib/initializers/giphy.rb' - 'lib/initializers/giphy_client.rb' # Offense count: 1 -# Cop supports --auto-correct. -Lint/UnneededCopEnableDirective: +# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS +Naming/FileName: Exclude: - - 'Gemfile' + - 'lib/slack-ruby-bot.rb' # Offense count: 2 # Configuration parameters: EnforcedStyle. @@ -51,27 +44,11 @@ Style/DoubleNegation: Exclude: - 'lib/slack-ruby-bot/commands/base.rb' -# Offense count: 5 -# Cop supports --auto-correct. -Style/ExpandPathArguments: - Exclude: - - 'lib/config/application.rb' - - 'lib/config/environment.rb' - - 'lib/slack-ruby-bot.rb' - - 'slack-ruby-bot.gemspec' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/IfUnlessModifier: - Exclude: - - 'lib/slack-ruby-bot/commands/support/match.rb' - - 'lib/slack-ruby-bot/mvc/controller/base.rb' - -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: module_function, extend_self -Style/ModuleFunction: +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: Exclude: - - 'lib/initializers/giphy_client.rb' - - 'lib/slack-ruby-bot/config.rb' + - 'spec/**/*' + - 'examples/market/marketbot.rb' diff --git a/.travis.yml b/.travis.yml index efb1cfa..9ad8a49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ cache: bundler matrix: include: - - rvm: 2.3.0 + - rvm: 2.6.5 script: - bundle exec danger - rvm: 2.3.0 @@ -12,14 +12,16 @@ matrix: - rvm: 2.3.0 env: CONCURRENCY=faye-websocket - rvm: 2.3.0 + env: CONCURRENCY=async-websocket + - rvm: 2.6.5 env: CONCURRENCY=celluloid-io WITH_GIPHY=true - - rvm: 2.3.0 + - rvm: 2.6.5 env: CONCURRENCY=faye-websocket WITH_GIPHY=true - - rvm: 2.3.0 + - rvm: 2.6.5 env: CONCURRENCY=celluloid-io WITH_GIPHY_CLIENT=true - - rvm: 2.3.0 + - rvm: 2.6.5 env: CONCURRENCY=faye-websocket WITH_GIPHY_CLIENT=true - - rvm: 2.5 + - rvm: 2.6.5 env: CONCURRENCY=async-websocket WITH_GIPHY_CLIENT=true - rvm: ruby-head - rvm: jruby-head diff --git a/CHANGELOG.md b/CHANGELOG.md index bb93843..b075aa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ -### 0.12.1 (Next) +### 0.13.0 (Next) * [#244](https://github.com/slack-ruby/slack-ruby-bot/pull/244): Change log message when the bot is reconnected - [@wasabigeek](https://github.com/wasabigeek). * [#209](https://github.com/slack-ruby/slack-ruby-bot/pull/209): Allow `respond_to_slack_message` and `respond_to_slack_messages` without arguments - [@dblock](https://github.com/dblock). * [#216](https://github.com/slack-ruby/slack-ruby-bot/pull/216): Added `start_typing` RSpec matcher - [@dblock](https://github.com/dblock). * [#214](https://github.com/slack-ruby/slack-ruby-bot/pull/214): Add passenger deployment documentation - [@cybercrediators](https://github.com/cybercrediators). * [#220](https://github.com/slack-ruby/slack-ruby-bot/pull/220): Updated examples/market to pull from IEX instead of defunct yahoo service - [@corprew](https://github.com/corprew). +* [#246](https://github.com/slack-ruby/slack-ruby-bot/pull/246): Drop support for Ruby 2.2 - [@dblock](https://github.com/dblock). * Your contribution here. diff --git a/Dangerfile b/Dangerfile index 4642bfe..10c6cd2 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1 +1,3 @@ +# frozen_string_literal: true + danger.import_dangerfile(gem: 'slack-ruby-danger') diff --git a/Gemfile b/Gemfile index 18f6a9c..1162fde 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' gemspec @@ -11,8 +13,6 @@ if ENV.key?('CONCURRENCY') end end -# rubocop:enable Bundler/OrderedGems - gem 'giphy', require: false if ENV.key?('WITH_GIPHY') gem 'GiphyClient', require: false if ENV.key?('WITH_GIPHY_CLIENT') diff --git a/LICENSE.md b/LICENSE.md index 7ad2bf4..a83576a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2015-2016 Daniel Doubrovkine, Artsy and Contributors +Copyright (c) 2015-2020 Daniel Doubrovkine, Artsy and Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index aa0db53..ea1e866 100644 --- a/README.md +++ b/README.md @@ -756,6 +756,6 @@ See [CHANGELOG](CHANGELOG.md) for a history of changes and [UPGRADING](UPGRADING ## Copyright and License -Copyright (c) 2015-2016, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md). +Copyright (c) 2015-2020, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md). This project is licensed under the [MIT License](LICENSE.md). diff --git a/Rakefile b/Rakefile index e6a99c1..fdc0636 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rubygems' require 'bundler' require 'bundler/gem_tasks' diff --git a/UPGRADING.md b/UPGRADING.md index 1ed6f76..3d61769 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,14 @@ Upgrading SlackRubyBot ====================== +### Upgrading to >= 0.13.0 + +#### Minimum Ruby Version + +Ruby 2.3 or later is now required. + +See [#246](https://github.com/slack-ruby/slack-ruby-bot/pull/246) for more information. + ### Upgrading to >= 0.12.0 #### Remove any references to `SlackRubyBot::Server#restart!` diff --git a/examples/inventory/Gemfile b/examples/inventory/Gemfile index 2083a89..36acb31 100644 --- a/examples/inventory/Gemfile +++ b/examples/inventory/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' gem 'celluloid-io' diff --git a/examples/inventory/inventorybot.rb b/examples/inventory/inventorybot.rb index 3ac29f6..6d778a8 100644 --- a/examples/inventory/inventorybot.rb +++ b/examples/inventory/inventorybot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'slack-ruby-bot' require 'sqlite3' @@ -56,6 +58,7 @@ def delete def notify_admin row = _row.first return if row[:quantity].to_i.zero? + view.email_admin("Inventory item #{row[:name]} needs to be refilled.") view.say(channel: data.channel, text: "Administrator notified via email to refill #{row[:name]}.") end @@ -93,6 +96,7 @@ def initialize count = 0 count += 1 while results.next return if count < 4 + add_item "'Audi',3,52642" add_item "'Mercedes',1,57127" add_item "'Skoda',5,9000" @@ -241,7 +245,7 @@ class InventoryBot < SlackRubyBot::Bot view = InventoryView.new @controller = InventoryController.new(model, view) @controller.class.command_class.routes.each do |route| - STDERR.puts route.inspect + warn route.inspect end end diff --git a/examples/market/Gemfile b/examples/market/Gemfile index e1511f1..653d55a 100644 --- a/examples/market/Gemfile +++ b/examples/market/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' gem 'faye-websocket' gem 'iex-ruby-client' diff --git a/examples/market/marketbot.rb b/examples/market/marketbot.rb index 0832021..50d2afb 100644 --- a/examples/market/marketbot.rb +++ b/examples/market/marketbot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'iex-ruby-client' require 'slack-ruby-bot' diff --git a/examples/minimal/Gemfile b/examples/minimal/Gemfile index b8b8389..596fd80 100644 --- a/examples/minimal/Gemfile +++ b/examples/minimal/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' gem 'celluloid-io' diff --git a/examples/minimal/pongbot.rb b/examples/minimal/pongbot.rb index a3717c9..b7b86c0 100644 --- a/examples/minimal/pongbot.rb +++ b/examples/minimal/pongbot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'slack-ruby-bot' class Bot < SlackRubyBot::Bot diff --git a/examples/weather/Gemfile b/examples/weather/Gemfile index b8b8389..596fd80 100644 --- a/examples/weather/Gemfile +++ b/examples/weather/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' gem 'celluloid-io' diff --git a/examples/weather/weatherbot.rb b/examples/weather/weatherbot.rb index c81c7fc..3af7a48 100644 --- a/examples/weather/weatherbot.rb +++ b/examples/weather/weatherbot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'slack-ruby-bot' SlackRubyBot::Client.logger.level = Logger::WARN diff --git a/lib/config/application.rb b/lib/config/application.rb index 3ffba84..5927294 100644 --- a/lib/config/application.rb +++ b/lib/config/application.rb @@ -1,12 +1,14 @@ +# frozen_string_literal: true + $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'boot' -Dir[File.expand_path('../../initializers', __FILE__) + '/**/*.rb'].each do |file| +Dir[File.expand_path('../initializers', __dir__) + '/**/*.rb'].sort.each do |file| require file end -require File.expand_path('../application', __FILE__) +require File.expand_path('application', __dir__) require 'slack_ruby_bot' diff --git a/lib/config/boot.rb b/lib/config/boot.rb index d515f99..d91254c 100644 --- a/lib/config/boot.rb +++ b/lib/config/boot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rubygems' require 'logger' require 'active_support' diff --git a/lib/config/environment.rb b/lib/config/environment.rb index f45d5f6..541cc29 100644 --- a/lib/config/environment.rb +++ b/lib/config/environment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV['RACK_ENV'] ||= 'development' -require File.expand_path('../application', __FILE__) +require File.expand_path('application', __dir__) diff --git a/lib/initializers/giphy.rb b/lib/initializers/giphy.rb index 5c84825..b424b42 100644 --- a/lib/initializers/giphy.rb +++ b/lib/initializers/giphy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'giphy' rescue LoadError diff --git a/lib/initializers/giphy_client.rb b/lib/initializers/giphy_client.rb index b4c0c19..582300a 100644 --- a/lib/initializers/giphy_client.rb +++ b/lib/initializers/giphy_client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'GiphyClient' diff --git a/lib/slack-ruby-bot.rb b/lib/slack-ruby-bot.rb index e7891ef..bfe5647 100644 --- a/lib/slack-ruby-bot.rb +++ b/lib/slack-ruby-bot.rb @@ -1,4 +1,6 @@ -require File.expand_path('../config/environment', __FILE__) +# frozen_string_literal: true + +require File.expand_path('config/environment', __dir__) require 'slack-ruby-bot/version' require 'slack-ruby-bot/support/loggable' diff --git a/lib/slack-ruby-bot/about.rb b/lib/slack-ruby-bot/about.rb index 987baf3..2e4d399 100644 --- a/lib/slack-ruby-bot/about.rb +++ b/lib/slack-ruby-bot/about.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + module SlackRubyBot - ABOUT = <<-ABOUT.freeze + ABOUT = <<-ABOUT #{SlackRubyBot::VERSION} https://github.com/slack-ruby/slack-ruby-bot https://twitter.com/dblockdotorg diff --git a/lib/slack-ruby-bot/app.rb b/lib/slack-ruby-bot/app.rb index 844f8a2..cd9b9a8 100644 --- a/lib/slack-ruby-bot/app.rb +++ b/lib/slack-ruby-bot/app.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot class App < Server def initialize(options = {}) diff --git a/lib/slack-ruby-bot/bot.rb b/lib/slack-ruby-bot/bot.rb index a70f70a..6ef526f 100644 --- a/lib/slack-ruby-bot/bot.rb +++ b/lib/slack-ruby-bot/bot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot class Bot < SlackRubyBot::Commands::Base delegate :client, to: :instance diff --git a/lib/slack-ruby-bot/client.rb b/lib/slack-ruby-bot/client.rb index fabe19c..b474890 100644 --- a/lib/slack-ruby-bot/client.rb +++ b/lib/slack-ruby-bot/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot class Client < Slack::RealTime::Client include Loggable @@ -31,11 +33,12 @@ def name?(name) def send_gifs? return false unless defined?(Giphy) + send_gifs.nil? ? SlackRubyBot::Config.send_gifs? : send_gifs end def name - SlackRubyBot.config.user || (self.self && self.self.name) + SlackRubyBot.config.user || self.self&.name end def url @@ -51,9 +54,9 @@ def say(options = {}) if keywords && send_gifs? gif = begin Giphy.random(keywords) - rescue StandardError => e - logger.warn "Giphy.random: #{e.message}" - nil + rescue StandardError => e + logger.warn "Giphy.random: #{e.message}" + nil end end text = [text, gif && gif.image_url.to_s].compact.join("\n") diff --git a/lib/slack-ruby-bot/commands.rb b/lib/slack-ruby-bot/commands.rb index 19979be..b129c7b 100644 --- a/lib/slack-ruby-bot/commands.rb +++ b/lib/slack-ruby-bot/commands.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'slack-ruby-bot/commands/base' require 'slack-ruby-bot/commands/about' require 'slack-ruby-bot/commands/help' diff --git a/lib/slack-ruby-bot/commands/about.rb b/lib/slack-ruby-bot/commands/about.rb index 0a18f8f..b82c6cd 100644 --- a/lib/slack-ruby-bot/commands/about.rb +++ b/lib/slack-ruby-bot/commands/about.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Commands class Default < Base diff --git a/lib/slack-ruby-bot/commands/base.rb b/lib/slack-ruby-bot/commands/base.rb index 284561a..40d5fa2 100644 --- a/lib/slack-ruby-bot/commands/base.rb +++ b/lib/slack-ruby-bot/commands/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'support/match' require_relative 'support/help' @@ -55,24 +57,30 @@ def invoke(client, data) finalize_routes! expression, text = parse(client, data) return false unless expression || data.attachments + routes.each_pair do |route, options| match_method = options[:match_method] case match_method when :match next unless expression + match = route.match(expression) match ||= route.match(text) if text next unless match next if match.names.include?('bot') && !client.name?(match['bot']) + match = Support::Match.new(match) when :scan next unless expression + match = expression.scan(route) next unless match.any? when :attachment next unless data.attachments && !data.attachments.empty? + match, attachment, field = match_attachments(data, route, options[:fields_to_scan]) next unless match + match = Support::Match.new(match, attachment, field) end call_command(client, data, match, options[:block]) @@ -122,6 +130,7 @@ def parse(client, data) text = data.text return text unless direct_message?(data) && message_from_another_user?(data) return text if message_begins_with_bot_mention?(text, client.names) + ["#{client.name} #{text}", text] end @@ -139,7 +148,8 @@ def message_begins_with_bot_mention?(text, bot_names) end def finalize_routes! - return if routes && routes.any? + return if routes&.any? + command command_name_from_class end @@ -148,6 +158,7 @@ def match_attachments(data, route, fields_to_scan = nil) data.attachments.each do |attachment| fields_to_scan.each do |field| next unless attachment[field] + match = route.match(attachment[field]) return match, attachment, field if match end diff --git a/lib/slack-ruby-bot/commands/help.rb b/lib/slack-ruby-bot/commands/help.rb index 247220c..df61d6a 100644 --- a/lib/slack-ruby-bot/commands/help.rb +++ b/lib/slack-ruby-bot/commands/help.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Commands class Help < Base @@ -24,16 +26,16 @@ class << self def general_text bot_desc = Support::Help.instance.bot_desc_and_commands other_commands_descs = Support::Help.instance.other_commands_descs - <* + For getting description of the command use: *help * -For more information see https://github.com/slack-ruby/slack-ruby-bot, please. -TEXT + For more information see https://github.com/slack-ruby/slack-ruby-bot, please. + TEXT end end end diff --git a/lib/slack-ruby-bot/commands/hi.rb b/lib/slack-ruby-bot/commands/hi.rb index cf49a6f..7467932 100644 --- a/lib/slack-ruby-bot/commands/hi.rb +++ b/lib/slack-ruby-bot/commands/hi.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Commands class Hi < Base diff --git a/lib/slack-ruby-bot/commands/support/attrs.rb b/lib/slack-ruby-bot/commands/support/attrs.rb index f4becda..514ed9e 100644 --- a/lib/slack-ruby-bot/commands/support/attrs.rb +++ b/lib/slack-ruby-bot/commands/support/attrs.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Commands module Support diff --git a/lib/slack-ruby-bot/commands/support/help.rb b/lib/slack-ruby-bot/commands/support/help.rb index f7433fa..05aabd6 100644 --- a/lib/slack-ruby-bot/commands/support/help.rb +++ b/lib/slack-ruby-bot/commands/support/help.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'singleton' require_relative 'attrs' @@ -34,12 +36,14 @@ def command_full_desc(name) help_attrs = find_command_help_attrs(unescaped_name) return "There's no command *#{unescaped_name}*" unless help_attrs return "There's no description for command *#{unescaped_name}*" if help_attrs.command_long_desc.blank? + "#{command_name_and_desc(help_attrs)}\n\n#{help_attrs.command_long_desc}" end def find_command_help_attrs(name) help_attrs = commands_help_attrs.find { |k| k.command_name == name } return help_attrs if help_attrs + commands_help_attrs.each { |k| k.commands.each { |c| return c if c.command_name == name } } nil end diff --git a/lib/slack-ruby-bot/commands/support/match.rb b/lib/slack-ruby-bot/commands/support/match.rb index 464c385..72d63e9 100644 --- a/lib/slack-ruby-bot/commands/support/match.rb +++ b/lib/slack-ruby-bot/commands/support/match.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Commands module Support @@ -9,9 +11,8 @@ class Match attr_reader :attachment, :attachment_field def initialize(match_data, attachment = nil, attachment_field = nil) - unless match_data.is_a? MatchData - raise ArgumentError, 'match_data should be a type of MatchData' - end + raise ArgumentError, 'match_data should be a type of MatchData' unless match_data.is_a? MatchData + @match_data = match_data @attachment = attachment @attachment_field = attachment_field diff --git a/lib/slack-ruby-bot/commands/unknown.rb b/lib/slack-ruby-bot/commands/unknown.rb index 44ccae3..530872d 100644 --- a/lib/slack-ruby-bot/commands/unknown.rb +++ b/lib/slack-ruby-bot/commands/unknown.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Commands class Unknown < Base diff --git a/lib/slack-ruby-bot/config.rb b/lib/slack-ruby-bot/config.rb index 965fd71..b81e9c1 100644 --- a/lib/slack-ruby-bot/config.rb +++ b/lib/slack-ruby-bot/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Config extend self @@ -11,6 +13,7 @@ def allow_message_loops? def send_gifs? return false unless defined?(Giphy) + v = boolean_from_env('SLACK_RUBY_BOT_SEND_GIFS') send_gifs.nil? ? (v.nil? || v) : send_gifs end diff --git a/lib/slack-ruby-bot/hooks.rb b/lib/slack-ruby-bot/hooks.rb index 1d88f9c..6c515c2 100644 --- a/lib/slack-ruby-bot/hooks.rb +++ b/lib/slack-ruby-bot/hooks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'slack-ruby-bot/hooks/set' require 'slack-ruby-bot/hooks/hello' require 'slack-ruby-bot/hooks/message' diff --git a/lib/slack-ruby-bot/hooks/hello.rb b/lib/slack-ruby-bot/hooks/hello.rb index 322af4a..78cfc40 100644 --- a/lib/slack-ruby-bot/hooks/hello.rb +++ b/lib/slack-ruby-bot/hooks/hello.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Hooks class Hello @@ -8,7 +10,8 @@ def initialize(logger) end def call(client, _data) - return unless client && client.team + return unless client&.team + new_connected_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) log = [ 'Successfully', diff --git a/lib/slack-ruby-bot/hooks/hook_support.rb b/lib/slack-ruby-bot/hooks/hook_support.rb index 16ea7c9..ee6811b 100644 --- a/lib/slack-ruby-bot/hooks/hook_support.rb +++ b/lib/slack-ruby-bot/hooks/hook_support.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Hooks module HookSupport diff --git a/lib/slack-ruby-bot/hooks/message.rb b/lib/slack-ruby-bot/hooks/message.rb index 7ff362e..16a1456 100644 --- a/lib/slack-ruby-bot/hooks/message.rb +++ b/lib/slack-ruby-bot/hooks/message.rb @@ -1,8 +1,11 @@ +# frozen_string_literal: true + module SlackRubyBot module Hooks class Message def call(client, data) return if message_to_self_not_allowed? && message_to_self?(client, data) + data.text = data.text.strip if data.text result = child_command_classes.detect { |d| d.invoke(client, data) } result ||= built_in_command_classes.detect { |d| d.invoke(client, data) } @@ -36,7 +39,7 @@ def command_classes # def child_command_classes command_classes.reject do |k| - k.name && k.name.starts_with?('SlackRubyBot::Commands::') + k.name&.starts_with?('SlackRubyBot::Commands::') end end @@ -47,7 +50,7 @@ def child_command_classes # def built_in_command_classes command_classes.select do |k| - k.name && k.name.starts_with?('SlackRubyBot::Commands::') && k != SlackRubyBot::Commands::Unknown + k.name&.starts_with?('SlackRubyBot::Commands::') && k != SlackRubyBot::Commands::Unknown end end end diff --git a/lib/slack-ruby-bot/hooks/set.rb b/lib/slack-ruby-bot/hooks/set.rb index dda528a..5967536 100644 --- a/lib/slack-ruby-bot/hooks/set.rb +++ b/lib/slack-ruby-bot/hooks/set.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Hooks class Set @@ -36,7 +38,7 @@ def register_callback(hook_name) end def flush_handlers - handlers.keys.each { |hook| register_callback(hook) } + handlers.each_key { |hook| register_callback(hook) } end end end diff --git a/lib/slack-ruby-bot/mvc.rb b/lib/slack-ruby-bot/mvc.rb index 680af7f..c178f70 100644 --- a/lib/slack-ruby-bot/mvc.rb +++ b/lib/slack-ruby-bot/mvc.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'slack-ruby-bot/mvc/mvc' diff --git a/lib/slack-ruby-bot/mvc/controller/base.rb b/lib/slack-ruby-bot/mvc/controller/base.rb index 89f879a..9770f3b 100644 --- a/lib/slack-ruby-bot/mvc/controller/base.rb +++ b/lib/slack-ruby-bot/mvc/controller/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module MVC module Controller @@ -45,9 +47,7 @@ def abstract! def inherited(klass) # :nodoc: # Define the abstract ivar on subclasses so that we don't get # uninitialized ivar warnings - unless klass.instance_variable_defined?(:@abstract) - klass.instance_variable_set(:@abstract, false) - end + klass.instance_variable_set(:@abstract, false) unless klass.instance_variable_defined?(:@abstract) super end @@ -64,6 +64,7 @@ def register_controller(controller) methods.each do |name| next if name[0] == '_' + commands = lookup_command_name(name) # Generates a command for each controller method *and* its aliases diff --git a/lib/slack-ruby-bot/mvc/model/base.rb b/lib/slack-ruby-bot/mvc/model/base.rb index 2ef586a..c4f8f8b 100644 --- a/lib/slack-ruby-bot/mvc/model/base.rb +++ b/lib/slack-ruby-bot/mvc/model/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module MVC module Model diff --git a/lib/slack-ruby-bot/mvc/mvc.rb b/lib/slack-ruby-bot/mvc/mvc.rb index 498f889..c8e2099 100644 --- a/lib/slack-ruby-bot/mvc/mvc.rb +++ b/lib/slack-ruby-bot/mvc/mvc.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../mvc/controller/base' require_relative '../mvc/model/base' diff --git a/lib/slack-ruby-bot/mvc/view/base.rb b/lib/slack-ruby-bot/mvc/view/base.rb index 052d975..161209a 100644 --- a/lib/slack-ruby-bot/mvc/view/base.rb +++ b/lib/slack-ruby-bot/mvc/view/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module MVC module View diff --git a/lib/slack-ruby-bot/rspec.rb b/lib/slack-ruby-bot/rspec.rb index cb6dbc3..523757a 100644 --- a/lib/slack-ruby-bot/rspec.rb +++ b/lib/slack-ruby-bot/rspec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..')) require 'rubygems' @@ -7,6 +9,6 @@ require 'config/environment' require 'slack-ruby-bot' -Dir[File.join(File.dirname(__FILE__), 'rspec/support', '**/*.rb')].each do |file| +Dir[File.join(File.dirname(__FILE__), 'rspec/support', '**/*.rb')].sort.each do |file| require file end diff --git a/lib/slack-ruby-bot/rspec/support/bots_for_tests.rb b/lib/slack-ruby-bot/rspec/support/bots_for_tests.rb index c477dce..283a029 100644 --- a/lib/slack-ruby-bot/rspec/support/bots_for_tests.rb +++ b/lib/slack-ruby-bot/rspec/support/bots_for_tests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Testing class WeatherBot < SlackRubyBot::Bot help do diff --git a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/it_behaves_like_a_slack_bot.rb b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/it_behaves_like_a_slack_bot.rb index 8764f2e..fc55e66 100644 --- a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/it_behaves_like_a_slack_bot.rb +++ b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/it_behaves_like_a_slack_bot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + shared_examples 'a slack ruby bot' do context 'not configured' do before do diff --git a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/not_respond.rb b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/not_respond.rb index c0a04eb..69a22c5 100644 --- a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/not_respond.rb +++ b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/not_respond.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec/expectations' RSpec::Matchers.define :not_respond do diff --git a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb index 962376b..ade6238 100644 --- a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb +++ b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_error.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec/expectations' RSpec::Matchers.define :respond_with_error do |error, error_message| diff --git a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb index 2d9d4f8..171c84a 100644 --- a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb +++ b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_message.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec/expectations' RSpec::Matchers.define :respond_with_slack_message do |expected| @@ -28,7 +30,7 @@ failure_message do |_actual| message = "expected to receive message with text: #{expected} once,\n received:" - message += @messages && @messages.any? ? @messages.inspect : 'none' + message += @messages&.any? ? @messages.inspect : 'none' message end end diff --git a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_messages.rb b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_messages.rb index 1298a38..4ac651a 100644 --- a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_messages.rb +++ b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/respond_with_slack_messages.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec/expectations' RSpec::Matchers.define :respond_with_slack_messages do |expected| @@ -22,7 +24,7 @@ @responses = [] - if expected && expected.any? + if expected&.any? expected.each do |exp| @responses.push(expect(client).to(have_received(:message).with(hash_including(channel: channel, text: exp)).once)) end @@ -34,7 +36,7 @@ end failure_message do |_actual| - if expected && expected.any? + if expected&.any? expected.map do |exp| "Expected text: #{exp}, got #{@messages[expected.index(exp)] || 'none'}" unless @responses[expected.index(exp)] end.compact.join("\n") diff --git a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/start_typing.rb b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/start_typing.rb index 1296842..a8948f6 100644 --- a/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/start_typing.rb +++ b/lib/slack-ruby-bot/rspec/support/slack-ruby-bot/start_typing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec/expectations' RSpec::Matchers.define :start_typing do |expected| @@ -16,7 +18,7 @@ message_command.call(client, Hashie::Mash.new(text: message, channel: channel, user: user, attachments: attachments)) matcher = have_received(:typing).once - matcher = matcher.with(expected) if expected && expected.any? + matcher = matcher.with(expected) if expected&.any? expect(client).to matcher true @@ -24,7 +26,7 @@ failure_message do |_actual| message = "expected to receive typing with: #{expected} once,\n received:" - message += @test_options && @test_options.any? ? @test_options.inspect : ' none' + message += @test_options&.any? ? @test_options.inspect : ' none' message end end diff --git a/lib/slack-ruby-bot/rspec/support/slack_api_key.rb b/lib/slack-ruby-bot/rspec/support/slack_api_key.rb index fdaff36..b7dca7b 100644 --- a/lib/slack-ruby-bot/rspec/support/slack_api_key.rb +++ b/lib/slack-ruby-bot/rspec/support/slack_api_key.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |config| config.before :all do ENV['SLACK_API_TOKEN'] ||= 'test' diff --git a/lib/slack-ruby-bot/rspec/support/slack_ruby_bot_configure.rb b/lib/slack-ruby-bot/rspec/support/slack_ruby_bot_configure.rb index 68306f2..333156c 100644 --- a/lib/slack-ruby-bot/rspec/support/slack_ruby_bot_configure.rb +++ b/lib/slack-ruby-bot/rspec/support/slack_ruby_bot_configure.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |config| config.before :each do SlackRubyBot.configure do |c| diff --git a/lib/slack-ruby-bot/rspec/support/spec_helpers.rb b/lib/slack-ruby-bot/rspec/support/spec_helpers.rb index c239da2..645611d 100644 --- a/lib/slack-ruby-bot/rspec/support/spec_helpers.rb +++ b/lib/slack-ruby-bot/rspec/support/spec_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module SpecHelpers private diff --git a/lib/slack-ruby-bot/rspec/support/vcr.rb b/lib/slack-ruby-bot/rspec/support/vcr.rb index 98a2292..46a3001 100644 --- a/lib/slack-ruby-bot/rspec/support/vcr.rb +++ b/lib/slack-ruby-bot/rspec/support/vcr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vcr' VCR.configure do |config| diff --git a/lib/slack-ruby-bot/server.rb b/lib/slack-ruby-bot/server.rb index 13cef5c..f8d5f2d 100644 --- a/lib/slack-ruby-bot/server.rb +++ b/lib/slack-ruby-bot/server.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot class Server include Loggable diff --git a/lib/slack-ruby-bot/support/loggable.rb b/lib/slack-ruby-bot/support/loggable.rb index e444505..96f36ec 100644 --- a/lib/slack-ruby-bot/support/loggable.rb +++ b/lib/slack-ruby-bot/support/loggable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot module Loggable def self.included(base) diff --git a/lib/slack-ruby-bot/version.rb b/lib/slack-ruby-bot/version.rb index 4cf87a5..0eab7b2 100644 --- a/lib/slack-ruby-bot/version.rb +++ b/lib/slack-ruby-bot/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SlackRubyBot - VERSION = '0.12.1'.freeze + VERSION = '0.13.0' end diff --git a/lib/slack_ruby_bot.rb b/lib/slack_ruby_bot.rb index d0060b0..c1b1513 100644 --- a/lib/slack_ruby_bot.rb +++ b/lib/slack_ruby_bot.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'slack-ruby-bot' diff --git a/slack-ruby-bot.gemspec b/slack-ruby-bot.gemspec index 901715c..2410e0e 100644 --- a/slack-ruby-bot.gemspec +++ b/slack-ruby-bot.gemspec @@ -1,4 +1,6 @@ -$LOAD_PATH.push File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +$LOAD_PATH.push File.expand_path('lib', __dir__) require 'slack-ruby-bot/version' Gem::Specification.new do |s| @@ -19,7 +21,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'rack-test' s.add_development_dependency 'rake' s.add_development_dependency 'rspec' - s.add_development_dependency 'rubocop', '0.58.2' + s.add_development_dependency 'rubocop', '0.80.1' s.add_development_dependency 'vcr' s.add_development_dependency 'webmock' end diff --git a/spec/slack-ruby-bot/app_spec.rb b/spec/slack-ruby-bot/app_spec.rb index 08e0d79..3341537 100644 --- a/spec/slack-ruby-bot/app_spec.rb +++ b/spec/slack-ruby-bot/app_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::App do def app SlackRubyBot::App.new diff --git a/spec/slack-ruby-bot/client_spec.rb b/spec/slack-ruby-bot/client_spec.rb index e7505a5..b6f037c 100644 --- a/spec/slack-ruby-bot/client_spec.rb +++ b/spec/slack-ruby-bot/client_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Client do describe '#send_gifs?' do context 'without giphy is false', unless: WithGiphy.env? do diff --git a/spec/slack-ruby-bot/commands/about_spec.rb b/spec/slack-ruby-bot/commands/about_spec.rb index 981cbd5..2b003a3 100644 --- a/spec/slack-ruby-bot/commands/about_spec.rb +++ b/spec/slack-ruby-bot/commands/about_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Default do it 'lowercase' do expect(message: SlackRubyBot.config.user).to respond_with_slack_message(SlackRubyBot::ABOUT) diff --git a/spec/slack-ruby-bot/commands/aliases_spec.rb b/spec/slack-ruby-bot/commands/aliases_spec.rb index 3c1a14e..c3fd177 100644 --- a/spec/slack-ruby-bot/commands/aliases_spec.rb +++ b/spec/slack-ruby-bot/commands/aliases_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot do def client SlackRubyBot::Client.new aliases: %w[:emoji: alias каспаров B0?.@(*^$] diff --git a/spec/slack-ruby-bot/commands/attachment_spec.rb b/spec/slack-ruby-bot/commands/attachment_spec.rb index 9087713..fe334e7 100644 --- a/spec/slack-ruby-bot/commands/attachment_spec.rb +++ b/spec/slack-ruby-bot/commands/attachment_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do context 'optional fields to scan' do let! :command do diff --git a/spec/slack-ruby-bot/commands/bot_message_spec.rb b/spec/slack-ruby-bot/commands/bot_message_spec.rb index b5efa51..6d1ce74 100644 --- a/spec/slack-ruby-bot/commands/bot_message_spec.rb +++ b/spec/slack-ruby-bot/commands/bot_message_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Unknown do def app SlackRubyBot::App.new diff --git a/spec/slack-ruby-bot/commands/bot_spec.rb b/spec/slack-ruby-bot/commands/bot_spec.rb index 96fcaec..4c83259 100644 --- a/spec/slack-ruby-bot/commands/bot_spec.rb +++ b/spec/slack-ruby-bot/commands/bot_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Bot do let! :command do Class.new(SlackRubyBot::Bot) do diff --git a/spec/slack-ruby-bot/commands/commands_command_classes_spec.rb b/spec/slack-ruby-bot/commands/commands_command_classes_spec.rb index 1f56c37..163fa8e 100644 --- a/spec/slack-ruby-bot/commands/commands_command_classes_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_command_classes_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Base do let! :command1 do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/commands_permitted_spec.rb b/spec/slack-ruby-bot/commands/commands_permitted_spec.rb index fb84451..0e38bbb 100644 --- a/spec/slack-ruby-bot/commands/commands_permitted_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_permitted_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands, 'permitted?' do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/commands_precedence_spec.rb b/spec/slack-ruby-bot/commands/commands_precedence_spec.rb index 34283d1..89a6639 100644 --- a/spec/slack-ruby-bot/commands/commands_precedence_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_precedence_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/commands_regexp_escape_spec.rb b/spec/slack-ruby-bot/commands/commands_regexp_escape_spec.rb index c769025..3dc54e3 100644 --- a/spec/slack-ruby-bot/commands/commands_regexp_escape_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_regexp_escape_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/commands_regexp_spec.rb b/spec/slack-ruby-bot/commands/commands_regexp_spec.rb index 9bd6f77..ed6ce86 100644 --- a/spec/slack-ruby-bot/commands/commands_regexp_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_regexp_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/commands_spaces_spec.rb b/spec/slack-ruby-bot/commands/commands_spaces_spec.rb index cc8b86c..5413e0a 100644 --- a/spec/slack-ruby-bot/commands/commands_spaces_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_spaces_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/commands_spec.rb b/spec/slack-ruby-bot/commands/commands_spec.rb index 0b1301c..a810612 100644 --- a/spec/slack-ruby-bot/commands/commands_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/commands_with_block_spec.rb b/spec/slack-ruby-bot/commands/commands_with_block_spec.rb index 51b951b..ec3cce4 100644 --- a/spec/slack-ruby-bot/commands/commands_with_block_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_with_block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/commands_with_expression_spec.rb b/spec/slack-ruby-bot/commands/commands_with_expression_spec.rb index c2611e7..90cea7d 100644 --- a/spec/slack-ruby-bot/commands/commands_with_expression_spec.rb +++ b/spec/slack-ruby-bot/commands/commands_with_expression_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/direct_messages_spec.rb b/spec/slack-ruby-bot/commands/direct_messages_spec.rb index 1978ecc..c7edd26 100644 --- a/spec/slack-ruby-bot/commands/direct_messages_spec.rb +++ b/spec/slack-ruby-bot/commands/direct_messages_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot do def app SlackRubyBot::App.new diff --git a/spec/slack-ruby-bot/commands/empty_text_spec.rb b/spec/slack-ruby-bot/commands/empty_text_spec.rb index 39b2696..d9ea28c 100644 --- a/spec/slack-ruby-bot/commands/empty_text_spec.rb +++ b/spec/slack-ruby-bot/commands/empty_text_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/help_spec.rb b/spec/slack-ruby-bot/commands/help_spec.rb index 107eea9..0628efa 100644 --- a/spec/slack-ruby-bot/commands/help_spec.rb +++ b/spec/slack-ruby-bot/commands/help_spec.rb @@ -1,25 +1,27 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Help do def app SlackRubyBot::App.new end it 'help' do - message = <?* - Tells you the weather in a . + *Commands:* + *clouds* - Tells you how many clouds there're above you. + *command_without_description* + *What's the weather in ?* - Tells you the weather in a . -*Other commands:* -*help* - Shows help information. -*hi* - Says hello. -*hello* - Says hello. + *Other commands:* + *help* - Shows help information. + *hi* - Says hello. + *hello* - Says hello. -For getting description of the command use: *help * + For getting description of the command use: *help * -For more information see https://github.com/slack-ruby/slack-ruby-bot, please. -MSG + For more information see https://github.com/slack-ruby/slack-ruby-bot, please. + MSG expect(message: "#{SlackRubyBot.config.user} help").to respond_with_slack_message(message) end diff --git a/spec/slack-ruby-bot/commands/hi_spec.rb b/spec/slack-ruby-bot/commands/hi_spec.rb index 003bd0a..1ff0adf 100644 --- a/spec/slack-ruby-bot/commands/hi_spec.rb +++ b/spec/slack-ruby-bot/commands/hi_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Hi do def app SlackRubyBot::App.new diff --git a/spec/slack-ruby-bot/commands/match_spec.rb b/spec/slack-ruby-bot/commands/match_spec.rb index 0f11ad0..d5d7514 100644 --- a/spec/slack-ruby-bot/commands/match_spec.rb +++ b/spec/slack-ruby-bot/commands/match_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/message_loop_spec.rb b/spec/slack-ruby-bot/commands/message_loop_spec.rb index 75ecad3..ce8f505 100644 --- a/spec/slack-ruby-bot/commands/message_loop_spec.rb +++ b/spec/slack-ruby-bot/commands/message_loop_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::App do def app SlackRubyBot::App.new diff --git a/spec/slack-ruby-bot/commands/nil_message_spec.rb b/spec/slack-ruby-bot/commands/nil_message_spec.rb index 42b819f..5bc0165 100644 --- a/spec/slack-ruby-bot/commands/nil_message_spec.rb +++ b/spec/slack-ruby-bot/commands/nil_message_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/not_implemented_spec.rb b/spec/slack-ruby-bot/commands/not_implemented_spec.rb index 1b4612c..f814b65 100644 --- a/spec/slack-ruby-bot/commands/not_implemented_spec.rb +++ b/spec/slack-ruby-bot/commands/not_implemented_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Base do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/operators_spec.rb b/spec/slack-ruby-bot/commands/operators_spec.rb index 56ed882..54794c3 100644 --- a/spec/slack-ruby-bot/commands/operators_spec.rb +++ b/spec/slack-ruby-bot/commands/operators_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/operators_with_block_spec.rb b/spec/slack-ruby-bot/commands/operators_with_block_spec.rb index cc36bdd..2482abe 100644 --- a/spec/slack-ruby-bot/commands/operators_with_block_spec.rb +++ b/spec/slack-ruby-bot/commands/operators_with_block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/scan_spec.rb b/spec/slack-ruby-bot/commands/scan_spec.rb index be9e867..60fa7d2 100644 --- a/spec/slack-ruby-bot/commands/scan_spec.rb +++ b/spec/slack-ruby-bot/commands/scan_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/send_gif_spec.rb b/spec/slack-ruby-bot/commands/send_gif_spec.rb index 5eb4b77..e9a8ca8 100644 --- a/spec/slack-ruby-bot/commands/send_gif_spec.rb +++ b/spec/slack-ruby-bot/commands/send_gif_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands, if: WithGiphy.env? do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/send_message_spec.rb b/spec/slack-ruby-bot/commands/send_message_spec.rb index 6e7d029..6b4b62a 100644 --- a/spec/slack-ruby-bot/commands/send_message_spec.rb +++ b/spec/slack-ruby-bot/commands/send_message_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/send_message_with_gif_spec.rb b/spec/slack-ruby-bot/commands/send_message_with_gif_spec.rb index 7c6c878..8e24efa 100644 --- a/spec/slack-ruby-bot/commands/send_message_with_gif_spec.rb +++ b/spec/slack-ruby-bot/commands/send_message_with_gif_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands, if: WithGiphy.env? do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/commands/support/attrs_spec.rb b/spec/slack-ruby-bot/commands/support/attrs_spec.rb index c7d0470..f29fbe7 100644 --- a/spec/slack-ruby-bot/commands/support/attrs_spec.rb +++ b/spec/slack-ruby-bot/commands/support/attrs_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Support::Attrs do let(:help_attrs) { described_class.new('WeatherBot') } diff --git a/spec/slack-ruby-bot/commands/support/help_spec.rb b/spec/slack-ruby-bot/commands/support/help_spec.rb index 638dfe8..21f8870 100644 --- a/spec/slack-ruby-bot/commands/support/help_spec.rb +++ b/spec/slack-ruby-bot/commands/support/help_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Support::Help do let(:bot_class) { Testing::WeatherBot } let(:command_class) { Testing::HelloCommand } diff --git a/spec/slack-ruby-bot/commands/support/match_spec.rb b/spec/slack-ruby-bot/commands/support/match_spec.rb index 9abf743..e3401ce 100644 --- a/spec/slack-ruby-bot/commands/support/match_spec.rb +++ b/spec/slack-ruby-bot/commands/support/match_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Support::Match do context 'initialized with invalid args' do subject { -> { described_class.new('invalid-match-data') } } diff --git a/spec/slack-ruby-bot/commands/unknown_spec.rb b/spec/slack-ruby-bot/commands/unknown_spec.rb index 0f862c4..a22181d 100644 --- a/spec/slack-ruby-bot/commands/unknown_spec.rb +++ b/spec/slack-ruby-bot/commands/unknown_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Commands::Unknown do it 'invalid command' do expect(message: "#{SlackRubyBot.config.user} foobar").to respond_with_slack_message("Sorry <@user>, I don't understand that command!") diff --git a/spec/slack-ruby-bot/config_spec.rb b/spec/slack-ruby-bot/config_spec.rb index fb82296..f63f97a 100644 --- a/spec/slack-ruby-bot/config_spec.rb +++ b/spec/slack-ruby-bot/config_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Config do describe '.send_gifs?' do after { ENV.delete 'SLACK_RUBY_BOT_SEND_GIFS' } diff --git a/spec/slack-ruby-bot/hooks/hello_spec.rb b/spec/slack-ruby-bot/hooks/hello_spec.rb index 74d5c1b..3ba7551 100644 --- a/spec/slack-ruby-bot/hooks/hello_spec.rb +++ b/spec/slack-ruby-bot/hooks/hello_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Hooks::Hello do let(:logger) { double(:logger, info: nil) } let(:hello_hook) { described_class.new(logger) } diff --git a/spec/slack-ruby-bot/hooks/hook_support_spec.rb b/spec/slack-ruby-bot/hooks/hook_support_spec.rb index 7b2cfae..fbbd5c2 100644 --- a/spec/slack-ruby-bot/hooks/hook_support_spec.rb +++ b/spec/slack-ruby-bot/hooks/hook_support_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Hooks::HookSupport do subject do Class.new do diff --git a/spec/slack-ruby-bot/hooks/message_spec.rb b/spec/slack-ruby-bot/hooks/message_spec.rb index eba6414..8fea110 100644 --- a/spec/slack-ruby-bot/hooks/message_spec.rb +++ b/spec/slack-ruby-bot/hooks/message_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Hooks::Message do let(:message_hook) { described_class.new } @@ -5,7 +7,7 @@ it 'doesn\'t raise an error when message is a frozen string' do message_hook.call( SlackRubyBot::Client.new, - Hashie::Mash.new(text: 'message'.freeze) + Hashie::Mash.new(text: 'message') ) end end diff --git a/spec/slack-ruby-bot/hooks/set_spec.rb b/spec/slack-ruby-bot/hooks/set_spec.rb index 56de6a3..d12da62 100644 --- a/spec/slack-ruby-bot/hooks/set_spec.rb +++ b/spec/slack-ruby-bot/hooks/set_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Hooks::Set do let(:client) { Slack::RealTime::Client.new } diff --git a/spec/slack-ruby-bot/initializers/giphy_client_spec.rb b/spec/slack-ruby-bot/initializers/giphy_client_spec.rb index 64055ec..76a17cd 100644 --- a/spec/slack-ruby-bot/initializers/giphy_client_spec.rb +++ b/spec/slack-ruby-bot/initializers/giphy_client_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if ENV.key?('WITH_GIPHY_CLIENT') describe Giphy do before do diff --git a/spec/slack-ruby-bot/initializers/giphy_spec.rb b/spec/slack-ruby-bot/initializers/giphy_spec.rb index 562e4d6..9fe20c7 100644 --- a/spec/slack-ruby-bot/initializers/giphy_spec.rb +++ b/spec/slack-ruby-bot/initializers/giphy_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if ENV.key?('WITH_GIPHY') describe Giphy do let(:burrito_gif) { 'https://media3.giphy.com/media/xTiTndNDuNFxUW5Xoc/giphy.gif' } diff --git a/spec/slack-ruby-bot/mvc/controller/controller_to_command_spec.rb b/spec/slack-ruby-bot/mvc/controller/controller_to_command_spec.rb index 09d47e0..9d31bef 100644 --- a/spec/slack-ruby-bot/mvc/controller/controller_to_command_spec.rb +++ b/spec/slack-ruby-bot/mvc/controller/controller_to_command_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::MVC::Controller::Base, 'initialization' do let(:model) { double('model') } let(:view) { double('view') } diff --git a/spec/slack-ruby-bot/rspec/respond_with_error_spec.rb b/spec/slack-ruby-bot/rspec/respond_with_error_spec.rb index 859b381..a2217c4 100644 --- a/spec/slack-ruby-bot/rspec/respond_with_error_spec.rb +++ b/spec/slack-ruby-bot/rspec/respond_with_error_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe RSpec do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/rspec/respond_with_slack_message_spec.rb b/spec/slack-ruby-bot/rspec/respond_with_slack_message_spec.rb index 881e1bc..61403d0 100644 --- a/spec/slack-ruby-bot/rspec/respond_with_slack_message_spec.rb +++ b/spec/slack-ruby-bot/rspec/respond_with_slack_message_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe RSpec do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/rspec/respond_with_slack_messages_spec.rb b/spec/slack-ruby-bot/rspec/respond_with_slack_messages_spec.rb index a13d569..32aa4be 100644 --- a/spec/slack-ruby-bot/rspec/respond_with_slack_messages_spec.rb +++ b/spec/slack-ruby-bot/rspec/respond_with_slack_messages_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe RSpec do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/rspec/start_typing_spec.rb b/spec/slack-ruby-bot/rspec/start_typing_spec.rb index 9a16f7d..c2bee60 100644 --- a/spec/slack-ruby-bot/rspec/start_typing_spec.rb +++ b/spec/slack-ruby-bot/rspec/start_typing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe RSpec do let! :command do Class.new(SlackRubyBot::Commands::Base) do diff --git a/spec/slack-ruby-bot/server_spec.rb b/spec/slack-ruby-bot/server_spec.rb index a1f0449..ae69010 100644 --- a/spec/slack-ruby-bot/server_spec.rb +++ b/spec/slack-ruby-bot/server_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Server do let(:logger) { subject.send :logger } let(:client) { Slack::RealTime::Client.new } diff --git a/spec/slack-ruby-bot/support/loggable_spec.rb b/spec/slack-ruby-bot/support/loggable_spec.rb index d1045d9..29f6dfa 100644 --- a/spec/slack-ruby-bot/support/loggable_spec.rb +++ b/spec/slack-ruby-bot/support/loggable_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot::Loggable do let!(:class_with_logger) { Class.new SlackRubyBot::Commands::Base } let!(:child_class_with_logger) { Class.new class_with_logger } diff --git a/spec/slack-ruby-bot/version_spec.rb b/spec/slack-ruby-bot/version_spec.rb index 99da7d5..add48d0 100644 --- a/spec/slack-ruby-bot/version_spec.rb +++ b/spec/slack-ruby-bot/version_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe SlackRubyBot do it 'has a version' do expect(SlackRubyBot::VERSION).to_not be nil diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 58c410d..5358437 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'slack-ruby-bot/rspec' require 'webmock/rspec'