Sha256: fb9a4f5c55cafca6c84005e615fa93810064c7d8e1b78e8a1b07b4d35594cd2b

Contents?: true

Size: 879 Bytes

Versions: 10

Compression:

Stored size: 879 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)

            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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
boty-0.0.16 lib/boty/rspec.rb
boty-0.0.15 lib/boty/rspec.rb
boty-0.0.14 lib/boty/rspec.rb
boty-0.0.13 lib/boty/rspec.rb
boty-0.0.12 lib/boty/rspec.rb
boty-0.0.11 lib/boty/rspec.rb
boty-0.0.10 lib/boty/rspec.rb
boty-0.0.9 lib/boty/rspec.rb
boty-0.0.7 lib/boty/rspec.rb
boty-0.0.6 lib/boty/rspec.rb