Sha256: e832a1a62b346bf02e5f7fd4eba75dff6a91a6daaa0fb0a9da15fd19a6a915ea

Contents?: true

Size: 805 Bytes

Versions: 1

Compression:

Stored size: 805 Bytes

Contents

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(ENV["SLACK_COMPANY"] || "acme")
            )

            class << bot
              attr_accessor :_response

              def say(message)
                @_response = message
              end
            end

            bot
          }
        end
      end

      def message_event(text)
        bot.event "type" => "message", "text" => text
      end
    end

    ::RSpec::Matchers.define :have_responded do |expected|
      match do |bot|
        response = bot._response
        bot._response = nil
        response == expected
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
boty-0.0.4 lib/boty/rspec.rb