diff --git a/Gemfile b/Gemfile index 706beac..a9c80b8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'http://rubygems.org' ruby '2.2.0' -gem 'slack-ruby-bot', '~> 0.3.0' +gem 'slack-ruby-bot' gem 'puma' gem 'sinatra' gem 'dentaku' diff --git a/Gemfile.lock b/Gemfile.lock index 725d866..dd3c8d8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,8 +9,8 @@ GEM tzinfo (~> 1.1) addressable (2.3.8) ast (2.0.0) - astrolabe (1.3.0) - parser (>= 2.2.0.pre.3, < 3.0) + astrolabe (1.3.1) + parser (~> 2.2) crack (0.4.2) safe_yaml (~> 1.0.0) dentaku (1.2.6) @@ -24,7 +24,7 @@ GEM faraday (~> 0.9.0) faraday_middleware (~> 0.9.1) oj (~> 2.0) - faye-websocket (0.9.2) + faye-websocket (0.10.0) eventmachine (>= 0.12.0) websocket-driver (>= 0.5.1) foreman (0.78.0) @@ -40,14 +40,12 @@ GEM launchy (2.4.3) addressable (~> 2.3) minitest (5.7.0) - multi_json (1.11.2) multipart-post (2.0.0) oj (2.12.10) - parser (2.3.0.pre.2) + parser (2.2.2.6) ast (>= 1.1, < 3.0) powerpack (0.1.1) - puma (2.11.3) - rack (>= 1.1, < 2.0) + puma (2.12.2) rack (1.6.4) rack-protection (1.5.3) rack @@ -59,12 +57,12 @@ GEM rspec-core (~> 3.3.0) rspec-expectations (~> 3.3.0) rspec-mocks (~> 3.3.0) - rspec-core (3.3.1) + rspec-core (3.3.2) rspec-support (~> 3.3.0) - rspec-expectations (3.3.0) + rspec-expectations (3.3.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.3.0) - rspec-mocks (3.3.1) + rspec-mocks (3.3.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.3.0) rspec-support (3.3.0) @@ -80,17 +78,17 @@ GEM rack (~> 1.4) rack-protection (~> 1.4) tilt (>= 1.3, < 3) - slack-api (1.1.6) - faraday (>= 0.7, < 0.10) - faraday_middleware (~> 0.8) - faye-websocket (~> 0.9.2) - multi_json (~> 1.0, >= 1.0.3) - slack-ruby-bot (0.3.0) + slack-ruby-bot (0.4.0) activesupport giphy (~> 2.0.2) hashie - slack-api (~> 1.1.6) + slack-ruby-client websocket-driver (~> 0.5.4) + slack-ruby-client (0.1.0) + eventmachine + faraday + faraday_middleware + faye-websocket thor (0.19.1) thread_safe (0.3.5) tilt (2.0.1) @@ -116,6 +114,6 @@ DEPENDENCIES rspec rubocop (= 0.31.0) sinatra - slack-ruby-bot (~> 0.3.0) + slack-ruby-bot vcr webmock diff --git a/slack-mathbot/commands/about.rb b/slack-mathbot/commands/about.rb index 7aaed2d..e4f0620 100644 --- a/slack-mathbot/commands/about.rb +++ b/slack-mathbot/commands/about.rb @@ -3,8 +3,8 @@ module SlackMathbot class Default < SlackRubyBot::Commands::Base match(/^(?\w*)$/) - def self.call(data, _match) - send_message_with_gif data.channel, SlackMathbot::ABOUT, 'math' + def self.call(client, data, _match) + send_message_with_gif client, data.channel, SlackMathbot::ABOUT, 'math' end end end diff --git a/slack-mathbot/commands/calculate.rb b/slack-mathbot/commands/calculate.rb index 15c7bbc..8df6976 100644 --- a/slack-mathbot/commands/calculate.rb +++ b/slack-mathbot/commands/calculate.rb @@ -4,16 +4,16 @@ module SlackMathbot operator '=' command 'calculate' - def self.call(data, match) + def self.call(client, data, match) result = Dentaku::Calculator.new.evaluate(match[:expression]) if match.names.include?('expression') result = result.to_s if result if result && result.length > 0 - send_message data.channel, result + send_message client, data.channel, result else - send_message_with_gif data.channel, 'Got nothing.', 'nothing' + send_message_with_gif client, data.channel, 'Got nothing.', 'nothing' end rescue StandardError => e - send_message_with_gif data.channel, "Sorry, #{e.message}.", 'idiot' + send_message_with_gif client, data.channel, "Sorry, #{e.message}.", 'idiot' end end end diff --git a/slack-mathbot/commands/help.rb b/slack-mathbot/commands/help.rb index 26c47d1..752566d 100644 --- a/slack-mathbot/commands/help.rb +++ b/slack-mathbot/commands/help.rb @@ -1,8 +1,8 @@ module SlackMathbot module Commands class Help < SlackRubyBot::Commands::Base - def self.call(data, _match) - send_message_with_gif data.channel, 'See https://github.com/dblock/slack-mathbot, please.', 'help' + def self.call(client, data, _match) + send_message_with_gif client, data.channel, 'See https://github.com/dblock/slack-mathbot, please.', 'help' end end end diff --git a/spec/slack-mathbot/commands/unknown_spec.rb b/spec/slack-mathbot/commands/unknown_spec.rb index 2bde2af..56e1d52 100644 --- a/spec/slack-mathbot/commands/unknown_spec.rb +++ b/spec/slack-mathbot/commands/unknown_spec.rb @@ -4,11 +4,12 @@ describe SlackRubyBot::Commands::Unknown do def app SlackMathbot::App.new end + let(:client) { app.send(:client) } it 'invalid command' do expect(message: 'mathbot foobar').to respond_with_slack_message("Sorry <@user>, I don't understand that command!") end it 'does not respond to sad face' do expect(SlackRubyBot::Commands::Base).to_not receive(:send_message) - SlackMathbot::App.new.send(:message, text: ':((') + SlackMathbot::App.new.send(:message, client, text: ':((') end end