Module: Bot::Rspec

Includes:
Matchers, Syntax
Defined in:
lib/bot/rspec.rb,
lib/bot/rspec/syntax.rb,
lib/bot/rspec/matchers.rb,
lib/bot/rspec/fixnum_helper.rb

Defined Under Namespace

Modules: FixnumHelper, Matchers, Syntax

Class Method Summary collapse

Methods included from Syntax

#incoming_message, #incoming_scan, #outgoing_message

Class Method Details

.included(base) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/bot/rspec.rb', line 12

def self.included(base)
  if base.[:type] == :responder
    base.let(:username) { "user" } unless base.respond_to? :username
    base.let(:user) { create(:user) } unless base.respond_to? :user
    base.let(:message) { incoming_message(user.username) } unless base.respond_to? :message
    base.let(:handler) { class_double("Handler") } unless base.respond_to? :handler
    base.let(:responses) { [] } unless base.respond_to? :responses
    base.let(:responder) { base.described_class.new(message, user, responses, handler) } unless base.respond_to? :responder
  end
end