Module: Boty::RSpec::Bot

Defined in:
lib/boty/rspec.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/boty/rspec.rb', line 6

def self.included(base)
  base.instance_eval do
    include SlackSupport::Users

    before do
      @_bot = Boty::Bot.new("id" => "1234", "name" => "bot")
      mock_post_message
    end

    let(:bot) { Boty::DSL.new @_bot }
  end
end

Instance Method Details

#event(options) ⇒ Object



30
31
32
# File 'lib/boty/rspec.rb', line 30

def event(options)
  @_bot.event({ "type" => "message" }.merge options)
end

#message(text) ⇒ Object



34
35
36
# File 'lib/boty/rspec.rb', line 34

def message(text)
  event "text" => text
end

#mock_post_messageObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/boty/rspec.rb', line 19

def mock_post_message
  class << Boty::Slack.chat
    attr_accessor :messages

    def post_message(message, options)
      @messages ||= []
      @messages << { message: message, options: options }
    end
  end
end