зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-07 19:35:52 +03:00
RSpec matchers
Этот коммит содержится в:
@@ -14,11 +14,14 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
|
||||
let(:bot_name) { 'bot' }
|
||||
let(:session) { controller.send(:session) }
|
||||
|
||||
include Telegram::Bot::RSpec::ClientMatchers
|
||||
|
||||
def dispatch(bot = self.bot, update = self.update)
|
||||
controller.dispatch_again(bot, update)
|
||||
end
|
||||
|
||||
def dispatch_message(text, options = {})
|
||||
def dispatch_message(text, options = nil)
|
||||
options ||= respond_to?(:default_message_options) ? default_message_options : {}
|
||||
update = build_update :message, options.merge(text: text)
|
||||
dispatch bot, update
|
||||
end
|
||||
@@ -34,4 +37,9 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
|
||||
else input
|
||||
end
|
||||
end
|
||||
|
||||
# Matcher to check response. Make sure to define `let(:chat_id)`.
|
||||
def respond_with_message(expected)
|
||||
send_telegram_message(bot, expected, chat_id: chat_id)
|
||||
end
|
||||
end
|
||||
|
||||
Ссылка в новой задаче
Block a user