From 557a4098007e0aaa250681acaf6720958f8ead93 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 10 Jul 2015 11:25:06 -0400 Subject: [PATCH] Set the bot name once. --- Gemfile.lock | 2 +- spec/slack-mathbot/commands/about_spec.rb | 3 --- spec/slack-mathbot/commands/calculate_spec.rb | 3 --- spec/slack-mathbot/commands/help_spec.rb | 3 --- spec/slack-mathbot/commands/hi_spec.rb | 3 --- spec/slack-mathbot/commands/unknown_spec.rb | 3 --- spec/spec_helper.rb | 5 +++++ spec/support/slack_mathbot.rb | 5 +++++ 8 files changed, 11 insertions(+), 16 deletions(-) create mode 100644 spec/support/slack_mathbot.rb diff --git a/Gemfile.lock b/Gemfile.lock index f6aa0b6..fda35b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/dblock/slack-ruby-bot.git - revision: edef7edd1c0e0f5abe70ab801593f4a2ef66766b + revision: 22f150f027d15c1a195692db0decf6bb4c850b7d specs: slack-ruby-bot (0.2.0) activesupport diff --git a/spec/slack-mathbot/commands/about_spec.rb b/spec/slack-mathbot/commands/about_spec.rb index d2bf9a5..c17dcc9 100644 --- a/spec/slack-mathbot/commands/about_spec.rb +++ b/spec/slack-mathbot/commands/about_spec.rb @@ -4,9 +4,6 @@ describe SlackMathbot::Commands::Default do def app SlackMathbot::App.new end - before do - app.config.user = 'mathbot' - end it 'mathbot' do expect(message: 'mathbot').to respond_with_slack_message(SlackMathbot::ABOUT) end diff --git a/spec/slack-mathbot/commands/calculate_spec.rb b/spec/slack-mathbot/commands/calculate_spec.rb index d4ded27..c828f20 100644 --- a/spec/slack-mathbot/commands/calculate_spec.rb +++ b/spec/slack-mathbot/commands/calculate_spec.rb @@ -4,9 +4,6 @@ describe SlackMathbot::Commands::Calculate, vcr: { cassette_name: 'user_info' } def app SlackMathbot::App.new end - before do - app.config.user = 'mathbot' - end it 'adds two numbers' do expect(message: 'mathbot calculate 2+2', channel: 'channel').to respond_with_slack_message('4') end diff --git a/spec/slack-mathbot/commands/help_spec.rb b/spec/slack-mathbot/commands/help_spec.rb index 51d7802..36c635b 100644 --- a/spec/slack-mathbot/commands/help_spec.rb +++ b/spec/slack-mathbot/commands/help_spec.rb @@ -4,9 +4,6 @@ describe SlackMathbot::Commands::Help do def app SlackMathbot::App.new end - before do - app.config.user = 'mathbot' - end it 'help' do expect(message: 'mathbot help').to respond_with_slack_message('See https://github.com/dblock/slack-mathbot, please.') end diff --git a/spec/slack-mathbot/commands/hi_spec.rb b/spec/slack-mathbot/commands/hi_spec.rb index 36bae0c..897610d 100644 --- a/spec/slack-mathbot/commands/hi_spec.rb +++ b/spec/slack-mathbot/commands/hi_spec.rb @@ -4,9 +4,6 @@ describe SlackRubyBot::Commands::Hi do def app SlackMathbot::App.new end - before do - app.config.user = 'mathbot' - end it 'says hi' do expect(message: 'mathbot hi').to respond_with_slack_message('Hi <@user>!') end diff --git a/spec/slack-mathbot/commands/unknown_spec.rb b/spec/slack-mathbot/commands/unknown_spec.rb index 0e4b521..8c7721c 100644 --- a/spec/slack-mathbot/commands/unknown_spec.rb +++ b/spec/slack-mathbot/commands/unknown_spec.rb @@ -4,9 +4,6 @@ describe SlackRubyBot::Commands::Unknown, vcr: { cassette_name: 'user_info' } do def app SlackMathbot::App.new end - before do - app.config.user = 'mathbot' - end it 'invalid command' do expect(message: 'mathbot foobar').to respond_with_slack_message("Sorry <@user>, I don't understand that command!") end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a7ae6cf..f878dc6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..')) require 'slack-ruby-bot/rspec' + +Dir[File.join(File.dirname(__FILE__), 'support', '**/*.rb')].each do |file| + require file +end + require 'slack-mathbot' diff --git a/spec/support/slack_mathbot.rb b/spec/support/slack_mathbot.rb new file mode 100644 index 0000000..e1bf327 --- /dev/null +++ b/spec/support/slack_mathbot.rb @@ -0,0 +1,5 @@ +RSpec.configure do |config| + config.before do + SlackRubyBot.config.user = 'mathbot' + end +end