module Boty module RSpec module Bot def self.included(base) base.instance_eval do let(:bot) { bot = Boty::Bot.new({"id" => "1234", "name" => "bot"}, Boty::Session.new) class << bot attr_accessor :_response def say(message) @_response = message end end bot } end end def event(options) bot.event({ "type" => "message" }.merge options) end def message_event(text) event "text" => text end end ::RSpec::Matchers.define :have_responded do |expected| # TODO: add proper messages for failures. match do |bot| response = bot._response bot._response = nil response == expected end end end end