1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-04 18:25:51 +03:00

ClientStub and improved rspec helpers

Этот коммит содержится в:
Max Melentiev
2016-02-28 21:53:54 +06:00
родитель bff412360e
Коммит f549ed53a5
6 изменённых файлов: 59 добавлений и 4 удалений

21
lib/telegram/bot/client_stub.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,21 @@
module Telegram
module Bot
# Stubbed client for tests. Saves all requests into #requests hash.
class ClientStub < Client
attr_reader :requests
def initialize(username = nil)
@username = username
reset
end
def reset
@requests = Hash.new { |h, k| h[k] = [] }
end
def request(action, body)
requests[action.to_sym] << body
end
end
end
end