зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-04 18:25:51 +03:00
ClientStub and improved rspec helpers
Этот коммит содержится в:
21
lib/telegram/bot/client_stub.rb
Обычный файл
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
|
||||
Ссылка в новой задаче
Block a user