module Boty module RSpec module Bot require File.expand_path "../../../spec/support/slack_support", __FILE__ def self.included(base) base.instance_eval do include SlackSupport::Users before do @_bot = Boty::Bot.new( {"id" => "1234", "name" => "bot"}, Boty::Session.new ) class << Boty::Slack.chat attr_accessor :messages def post_message(message, options) @messages ||= [] @messages << { message: message, options: options } end end end let(:bot) { Boty::ScriptDSL.new @_bot } end end def event(options) @_bot.event({ "type" => "message" }.merge options) end def message(text) event "text" => text end end ::RSpec::Matchers.define :have_responded do |expected| # TODO: add proper messages for failures. match do |dsl| last_message = Slack.chat.messages.last expected == last_message[:message] end end end end